Glad it's working! To answer your questions first:
Quote:
can I directly insert my fields as ......
awk -F "," -v c1=${31:-31} -v c2=${36:-36} '....and run the script as
./test_sh.........which will read the data from the file script_test.txt......????
Yes, but you will need to redirect your file in like this:
Quote:
1) I have to cat my file and put filter for $49....as this field had 4 values.....1,2,3,4..........and then I have to process the above entire code for each value respectively.....
so can I use this code like......
Yes, but you don't need cat. Awk can read the file directly so something like this:
However, you can have the programme that generates the matrix make a single pass across your input data and generate all 4 (or however many different values $49 has) matrices. Given that, the script below will print one matrix for each unique value in $49. Thus, there is no need to run the preprocess script that prints only records where $49 == 1 etc.
It will take from the command line, in this order, the column to print vertically, the column to print horizontally, the column which identifies the matrix. If no parms are given, then the defaults are 31 (vert) 36 (horiz) and 49 (id column).
Finally, in the special case where c1 has the value of 255, and $13 is non-zero, the count will be updated as though the value of c1 was zero.
Assuming you save this file in /home/userx/bin/gen_matrix.ksh and your test data is always in /usr2/data/matrix_input.csv, then you can schedule your job in cron with this command:
It will always write the output to the same file. If your input file will be different each day (maybe having the date), or you want your output file to be diffent each day (again with the date), then you will need to construct your input and output filenames in the script and use them on the awk command. Your cron command then just consists of the name of the script.
Examples of this:
Hope this gets you further along.
Last edited by agama; 08-10-2011 at 10:08 PM..
Reason: typo
Hi guys, I hope you can help me with my problem.
I have a text file that contains lines like this:
78 ANGELO -809.05
79 ANGELO2 -5,000.06
I need to find all occurences of amounts that are negative and replace them with x's
78 ANGELO xxxxxxx
79... (4 Replies)
Hi,
Need to extract a string from one file and search the same in other files.
Ex:
I have file1 of hundred lines with no delimiters not even space.
I have 3 more files.
I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Hi all,
I am having a problem in comparing numeric value with string.
I have a variable in my script which gets the value dynamically. It can be a numeric value or a string.
I have to do separate task based on its value numeric or sting variable VARIABLE.
I grep FILE_COUNT and obtained... (7 Replies)
Hi frnds
Im facing an issues while trying to compare string using IF stmt, my code is:
chkMsgName=`Service Fee Detail`
if
then
if
then
if
then
echo "Valid File Ready for processing"
fi
fi
... (5 Replies)
Hi everyone,
I am working on fetchmail + procmail to filter mails and I am having problem with parsing a long line in the body of the email.
Could anyone help me construct a reg exp for this string below. It needs to match exactly as this string.
GetRyt... (4 Replies)
Hi All,
I am trying to to compare a string variable with a string literal inside a loop but keep getting the
./testifstructure.sh: line 6:
#!/bin/sh
BOOK_LIST="BOOK1 BOOK2"
for BOOK in ${BOOK_LIST}
do
if
then echo '1'
else
echo '2'
fi
done
Please use next... (1 Reply)
I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Hi ,
I have one file like
BUD,BDL BUDCAR
BUD,BDL BUDLAMP
ABC,CDF,KLT ABISKAR
ABC,CDF,KLT CORNEL
ABC,CDF,KLT KANNAD
JKL,HNM,KTY,KJY JAGAN
JKL,HNM,KTY,KJY HOUSE
JKL,HNM,KTY,KJY KATAK
JKL,HNM,KTY,KJY KOLKA
The o/p should be like
BUD,BDL BUDCAR,BUDLAMP
ABC,CDF,KLT... (4 Replies)
Hi,
I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat.
My OS is:
SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
Good morning,
I need compare this string.
if || || ; then
But this line not work, somebody can say me what is the error.
Thank you for advanced. (5 Replies)