![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help needed | nnayagam | Shell Programming and Scripting | 2 | 03-07-2008 06:34 AM |
| Little help needed. | Netghost | AIX | 5 | 08-10-2006 03:29 PM |
| Help needed | dsravan | Shell Programming and Scripting | 2 | 07-20-2006 10:37 AM |
| awk help needed. | cskumar | Shell Programming and Scripting | 0 | 07-20-2006 08:24 AM |
| Sed help needed | stevefox | Shell Programming and Scripting | 5 | 12-05-2005 01:44 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|