Hi, I'm a bit stuck on this. If I try to assign a variable as the result of a command output that parses a text file, and then try and use that variable later on eg. bc it doesn't work. The latest error gives me
(standard_in) 1: illegal character: ^M
So for example if I try to use awk to extract line 26, which looks like this:
and assign it to a variable "POINTS":
POINTS=$(cat blahblah.txt | awk "NR==26")
produces the output "50" as expected,
but when I try and multiply the output by 2:
NEWVALUE=$(echo "$POINTS * 2" | bc) echo $NEWVALUE
Gives the illegal character error above. Strangely, if I put
above the bc calculation line, it all works properly.
EDIT- FORGET IT
I think it's DOS format text crappy crap problem. Nevermind.
Oh, and I'll mark this solved after I've had my cup of tea. And after I've checked it really is solved of course...
Last edited by darkbeanies (2012-08-26 15:08:09)
get dos2unix to convert the files first.
yup, dos2unix fixed all problems. Hoorah!