|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Emergency UNIX and Linux Support !! Help Me!! Post your urgent questions here for highest visibility. Posting a new thread to this forum requires Bits. We monitor this forum to help people with emergencies, but we do not guarantee response time or answers. This forum is "best effort" only. Members who reply to posts here receive a bonus of 1000 Bits per reply. |
![]() |
|
|
Search this Thread |
|
#1
|
|||
|
|||
|
awk- add columns and make new column and save as newfile
Hi,
I have file as below: 5 6 7 4 8 9 3 5 6 output needs to be another file with 4th column as $1+$2 and 5th column as $3+$4. sample output file 5 6 7 11 18 4 8 9 12 21 3 5 6 8 14 Anybody have answer Thanks in advance Vasanth |
| Sponsored Links | ||
|
|
|
#2
|
||||
|
||||
|
That's almost too simple: Code:
$ cat test.txt
5 6 7
4 8 9
3 5 6
$ awk '{print $1,$2,$3,$1+$2,$1+$2+$3}' test.txt
5 6 7 11 18
4 8 9 12 21
3 5 6 8 14 |
|
#3
|
|||
|
|||
|
Or : Code:
awk '{$4=$1+$2;$5=$3+$4}1' infile |
|
#4
|
|||
|
|||
|
oh....
thanks...
|
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help sum columns by break in first column with awk or sed or something. | syadnom | Shell Programming and Scripting | 6 | 02-01-2009 04:23 AM |
| Convert two column data into 8 columns | NickC | Shell Programming and Scripting | 8 | 06-28-2008 11:19 AM |
| Single column to multiple columns in awk | astroDave | Shell Programming and Scripting | 2 | 03-27-2008 09:00 PM |
| How to check Null values in a file column by column if columns are Not NULLs | Mandab | Shell Programming and Scripting | 7 | 03-15-2008 08:57 AM |
| Print last 4 columns (variable column #) | Da_Duck | UNIX for Dummies Questions & Answers | 19 | 02-27-2004 09:33 AM |