Search Results

Search: Posts Made By: ramneim
4,344
Posted By Don Cragun
You may want to trap on conditions 0 1 2 3 and...
You may want to trap on conditions 0 1 2 3 and 15. 3 does mean that the process was terminated by a SIGQUIT signal, but that is not normal termination. 0 is normal termination (i.e., terminated by...
4,344
Posted By Chubler_XL
Yes a dummy files is being created with just the...
Yes a dummy files is being created with just the header line of "dummy" the trap command is designed to ensure these dummy files are cleaned up, even when you ctrl-c or kill the script.

The...
4,344
Posted By Chubler_XL
How about this: #!/usr/bin/sh FILES="$1" ...
How about this:
#!/usr/bin/sh
FILES="$1"
DELIMITER="$2"
COL_LIST=$3
EXC_FILE=${4:-/dev/null}

for FILE in $FILES
do
gzip -t ${FILE} 2>/dev/null
if [ $? -eq 1 ]
then
...
4,344
Posted By Chubler_XL
Sorry about the delay in my reply. Real life...
Sorry about the delay in my reply. Real life caught up with me for a bit there. I'll try an answer your questions in order:



Spot on, the variable col_list is "22,23,1,2,4" and the split...
2,075
Posted By RudiC
Run script with options -vx set and post the...
Run script with options -vx set and post the output (probably best as an attachment).
2,075
Posted By RudiC
1) You don't list the line in question (36 or...
1) You don't list the line in question (36 or 39).
2) Looks like there is a <carriage return> (^M or \r or 0x0D) char in one of your parameters, probably $1.
2,075
Posted By elixir_sinari
Seems carriage-return characters are in your...
Seems carriage-return characters are in your file. How did you get this file? From a Windows machine? FTP? binary mode?
Use dos2unix utility on the file.
4,344
Posted By Chubler_XL
So now you see the problem with using the number...
So now you see the problem with using the number of arguments to control your script logic - it makes it hard to add optional parameters later.

How about a slight change to your input...
4,344
Posted By Chubler_XL
I'd suggest using another env var for the exclude...
I'd suggest using another env var for the exclude filename e.g. EXC_FILE and default this to /dev/null when none.

Change script to like this:

$comm $FILE | awk -v col=$FIRST_COL -v...
3,278
Posted By Corona688
Load data from the files in the BEGIN section and...
Load data from the files in the BEGIN section and put them in an array.

When reading lines of data, check then if the array for that entry is blank like if(SKIP[$col]) { next } where 'next' will...
3,278
Posted By Corona688
You can use arrays to group the data. Instead of...
You can use arrays to group the data. Instead of X += Y, you can do X[index] += Y, where 'index' can be one column or several columns, like X[$1","$2","$3] += $4

Then you can loop over the array...
3,278
Posted By Corona688
We can't just hand you an answer. We can help...
We can't just hand you an answer. We can help you build something but can't do the whole thing.

You can sum in awk like this: awk '{
for(N=4; N<=NF; N++) A[$1","$2","$3","N]+=$N
...
3,278
Posted By Corona688
You can't put a BEGIN statement in an if...
You can't put a BEGIN statement in an if statement. Like END, it has to be outside by itself. You can put an if statement in a begin statement though.

Yes, you can specify paths to getline. ...
3,278
Posted By Corona688
The getline loop won't run if the file doesn't...
The getline loop won't run if the file doesn't exist. An if might not be necessary. Put them in the array, too. If you somehow arrange for B["12345"]=1 to be set before the real data gets checked,...
Showing results 1 to 14 of 14

 
All times are GMT -4. The time now is 02:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy