![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help needed | nnayagam | Shell Programming and Scripting | 2 | 03-07-2008 03:34 AM |
| Little help needed. | Netghost | AIX | 5 | 08-10-2006 11:29 AM |
| Help needed | dsravan | Shell Programming and Scripting | 2 | 07-20-2006 06:37 AM |
| awk help needed. | cskumar | Shell Programming and Scripting | 0 | 07-20-2006 04:24 AM |
| Sed help needed | stevefox | Shell Programming and Scripting | 5 | 12-04-2005 10:44 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help needed in awk
Hi All,
I am trying to manipulate a file using awk in UNIX. My file "test_file" is structured as follows: field1:field2:field3 field4:field5:field6 field7:field8:field9 My requirement is to calculate another field (which would be let's say sum of 2nd and third column and put as fourth column in this file). so that my final output would be field1:field2:field3:fieldA field4:field5:field6:fieldB field7:field8:field9:fieldC where fieldA=field2 + field3 and so on... I have the following piece of code which I guess, is nowhere in the working condition right now: while read line do echo $line | awk -F: 'BEGIN {OFS=":"} {$4=$2 + $3 ; print $0}' >> new_test_file done < test_file I read somewhere that you can dynamically calculate variables in awk, so $4 would be dynamically calculated at the run time. Subsequently when i print $0 should contain the new calculated field too. But I guess that is not the case. Can anybody look into above and help me out? Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
oops!! duplicate submission. Plz ignore this thread
I guess by mistake i submitted this twice. Plz ignore this one.
Thanks |
|||
| Google The UNIX and Linux Forums |