non-numeric argument from output
Hello:
I'm using the following: Fedora 6 2.6.18.1 bash I'm extracting a numeric value from a file into a variable. I fail to then perform expr on the the var due to 'non-numeric argument' Below I am pasting the output from my screen: # grep octets my.out|awk '{print $4}' 20850897 # myvar=`grep octets my.out|awk '{print $4}'` # echo $myvar 20850897 # expr $myvar + 1 expr: non-numeric argument # myvar=20850897 # echo $myvar 20850897 # expr $myvar + 1 20850898 The my.out file contains output from an expect script. I can only assume this file has some hidden characters that render my variables 'non-numeric'. I have tried sending the output first into another file to rid it of hidden characters, but still it fails. You can see below that the file containing the output will allways be 1 char larger than a 'clean' file. I can't explain this. # grep octets my.out|awk '{print $4}' 20850897 # grep octets my.out|awk '{print $4}' > my.out2 # cat my.out2 20850897 # echo 20850897 > my.out3 # cat my.out3 20850897 # ll my.out* -rw-r--r-- 1 root root 10 May 2 16:02 my.out2 -rw-r--r-- 1 root root 9 May 2 16:02 my.out3 Thanks for any help, Dan |
Try this?
Code:
myvar="20850897 \\x0^V^J" # meaning CTRL+V,CTRL+J |
Thanks so much. That solved the problem.
|
All times are GMT -5. The time now is 02:14 PM. |