You are not logged in.
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:
50
and assign it to a variable "POINTS":
POINTS=$(cat blahblah.txt | awk "NR==26")
echo $POINTS
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
POINTS=50
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)
Offline
get dos2unix to convert the files first.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
yup, dos2unix fixed all problems. Hoorah!
Offline