mercredi 8 novembre 2017

Using awk to sum an integer to a column in bash

I have a file (tmp0.tmp) of one column with negative and positive values, like this:

-109.372
-152.846
121.435
122.107
-1.172
-118.116

I want to sum 360 to each negative value, and keep the positive ones in the same position.

I did:

for file in tmp0.tmp
do
awk '{if ($1 < 0) {print $1+360} elseif {print $1}' $file > histogram.dat
done

and it didn't work.

Can anyone help me please?

Thanks

Aucun commentaire:

Enregistrer un commentaire