The title says it all. I know that this is possible when not reading a file because this works. However, when I try to modify it to read a value from a file, I get weird results...
$ num1="1.291858E+01"
$ num2="1E-5"
$ echo $num1'>'$num2
1.291858E+01>1E-5
$ cat sum.csv
1.291858e+01
$ num1=`cat sum.csv | sed -e 's/e/E/'`
$ echo $num1
1.291858E+01
$ echo $num1'>'$num2
>1E-5858E+01
Edit:
I would expect the outcome to be
1.291858E+01>1E-5
And here is what I'm copying directly from the terminal
test $ num1="1.291858E+01"
test $ num2="1E-5"
test $ echo $num1'>'$num2
1.291858E+01>1E-5
test $ cat sum.csv
1.291858e+01
test $ num1=`cat sum.csv | sed -e 's/e/E/'`
test $ echo $num1
1.291858E+01
test $ echo $num1'>'$num2
>1E-5858E+01
test $
Your lines end in control-Ms in sum.csv, presumably because it was create on Windows. Use cat -v sum.csv
to see them and run dos2unix
or similar to remove them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.