First off, this is not homework nor for any class.
I have a file (column) of data such as:
12.56
2.78
0.54
22.7
... etc.
(call the file "num") I want to read in each line, then check to see whether it's greater than or equal to a value, say "1". If it is, save it in one file, if it's not, save it in another file. So in other words, I'll end up with two files, each a column of data. Below is what I tried:
read a < num
if [ "${a}" -ge 1 ]; then
${a} >> OK.txt
else
${a} >> BAD.txt
fi
It appears to work for the very first line, but then stops. I'm sure there's a simple way to get what I want, but I don't know how. Help, would certainly be appreciated! Thanks.
Thanks Ygor, that *almost* works!
The problem I get is that for some reason no values are written to OK.txt
Also, for each line that is run, I get an error similar to this:
./num.sh[26]: 1.3004: not found [No such file or directory]
so for the above value (1.3004) it does not write it to OK.txt
However, it appears to write out the values that it should to BAD.txt for some reason? I don't know if it matters, but I'm running the script in ksh. Thanks!