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

That's almost too simple:

$ 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

Or :

awk '{$4=$1+$2;$5=$3+$4}1' infile

thanks...