I have a file listed like this:
-180.0564 -179.0857 178.4739 ... ... ...
So I need to look through all the file and change only the positive (or negative) values subtracting an interger like 100 or in my case 360. I develop this code looking in the web and I'm using the bc command for the floating operations. The problem is that is changing now all the negative values instead of the positive ones and I cannot understand why.
Here's the code:
#!/bin/bash
FILE=$1
while read line;do
if [ $(echo $line '>' 0.0 |bc -l) ]; then
line=$(echo "$line-360" |bc)
echo $line
else
echo $line
fi
done < $FILE
Thanks
Aucun commentaire:
Enregistrer un commentaire