I have following set of code [1] which I want to modify
In the given code, the given PATH535 only accept the single path.
I would like to modify it to make it array and should be able to pass several
of the path address together.
for example like following:
And the code works for all the files kept at these locations of PATH535[] array?
I partially agree with ctsgnb, and partly disagree. With all of the things that are not shown to us, I don't know if this script is optimized or extremely inefficient.
Here is your script again (after setting up PATH535 to be the array of 3 pathnames as you indicated you wanted to do earlier in your problem description) with line numbers added for discussion purposes:
Since I have no idea what is in your log files, nor how the variables CONSTANT, File0, and FileName have been initialized before you call your doCheck() function, I can't make any educated guess as to what you're trying to do, but a few things look strange:
I would expect the variable name FileNameIndex to be an index into an array named FileName. But starting on line 6, you use FileNameIndx as the name of a file (of type directory) from the array PATH535.
On line 8 you check to see if a directory exists in a sub-directory of your current working directory. If it doesn't exist, you perform several operations, but none of them create the directory that you were looking for.
On line 9, OFS=\t sets the output field separator for this awk command to t; not to a <tab> character. (If you want a <tab> character, change it to OFS='\t'.)
Line 15 seems a bit strange. Why say:
when what it really means is:
The do on line 7 doesn't have a matching done. Presumably the missing done should be added before or after line 17.
This User Gave Thanks to Don Cragun For This Post:
Hi Don Cragun,
I appreciate your reply and the time you spend on that piece of code.
I completely agree with you and ctsgnb that code is far from optimization.
Being novice with shell scripting, I was happy with the idea that I could make working script which looks nasty but does my task pretty well. And the sole reason to post the question here was try to optimize it. That also make me learn more of shell scripting.
Now, Let me explain you the task of this piece of the script.
I have several of the files kept at some locations like
And my purpose is to copy them in one common file named $FileName. Important is to make sure that if there is any repeating of files than only the file with the bigger size should be kept.
Repeating would implies, in the given example the deciding critera is to match the no '187' and if there are three different files, go for copying the file name vgtree_187_1_cda.root
Following this criteria I want a final file $DataFile with the content as:
And the following as I explained for single $PATH would infect be repeated for several of PATH and with millions of root files.
or
Depending on the implementation, the "sort" command may need some tweak so that it displays files by number
and if several index (ex: _1 _2 _3) for a same file number (187) it displays the biggest in size at first.
As far as i tested, the output given by the sort command works fine on my Ubuntu.
Once the file are sorted that way, it build the initial base name of a file number (that is contained in i) then print only the first met and add it into your big file.
appending this into the big file could also be added within awk using the "system" command (if so, remember to close each file after concatenation into the big one).
Hi all,
I have an input file like below (a comma seperated file)
345,12,10
400,11,8
328,1,3
I need to get the output as below ...
record 345 sum is 12
record 400 sum is 10
record 328 sum is 1
record 345 count is 10
record 400 count is 8
record 328 count... (15 Replies)
hi Team,
i need a help in perl ,
i need to get values(10 rows +) from perl GUI and insert those values into oracle table.
am trying to achive this in Perl array, can you please help me on this.
thanks
senthil (1 Reply)
I have a script that send email using sendEmail (CentOS shell)
script is:
sendEmail -vvv -u "TestCompany, Inc.: USB Added" -f user@domain.com -t To@domain.com -s ASPMX.L.GOOGLE.com -m "USB Activity" -o tls=aut
o username=user3@domain.com password=password
So far this works fine.
Now i... (5 Replies)
Hi All,
I need to store the output of "find ." to an array one by one. Output of find . in my case will look like :-
.
./one
./one/a
./one/b
./one/c
./two
So my first array element should be "/one" and second one "/one/a" (need to remove "." from the output as well).
Then I need to... (11 Replies)
Below is my script. This script is getting an error code such as this one.
fileListener.bat: entityArray=craig.uss@pnc.com: not found
craig.uss@pnc.com
fileListener.bat: entityArray=duns_noncusts.txt: not found
duns_noncusts.txt
fileListener.bat: entityArray=duns_misc.cpy: not found... (4 Replies)
hi all......
i want to use an array ,declared in bash, in embedded perl script.
is there any way to export whole array so that i can use it '$ENV{}' or something..
thanx in advance!!
regards,
prayush (1 Reply)
Hi All,
I'm trying to get a script to loop through an array. The array is basically a list of .zip files. I'd like the script to loop through and unzip the zip files contained in the zip file list. When I run the script, it unzip the first zip file correctly, and then stops Any thoughts? Here's... (2 Replies)
Here is the script. I am not able to increment and Print echo "2=" ${arr}
(Bold line)
Can someone please help me correct it? I am thinking there is some escape sequence error. Just started learning scripts ...
Thanks
#!/bin/ksh
set -A arr a1 a2 a3 a4
# START
Server1=gmi
... (6 Replies)