Operations inside a file

Hi all,
i need to do a piecewise integration between this example data inside a file :

500856704.00 11536282.5600897 50496
500402784.00 11538000.3654401 -453920
500654880.00 11538000.4662785 252096
500604416.00 11539718.4330113 -50464
500907168.00 11539718.5541121 302752
500705280.00 11541436.4602753 -201888

I should add the first column (x) to the second (y) and multiply by the 3th (tau)
Is there a way to do it by command line?

Thanks in advance

Regards

Try:

awk '{ printf "%f\n",$3*($1+$2)}' filename
1 Like
perl -lane 'print ($F[1]+$F[2])*$F[3]' inputfile
1 Like

can i ask also how to add an additional row with for example 1.000 ?

Imagine, for the code above to add a column of 1000 at each line present in the file

Thanks!

---------- Post updated at 12:47 PM ---------- Previous update was at 11:24 AM ----------

awk '{print $0, "10000.00"}' file 

got it thanks