0

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 $
Community
  • 1
  • 1
user1543042
  • 3,422
  • 1
  • 17
  • 31

1 Answers1

3

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.

Ed Morton
  • 188,023
  • 17
  • 78
  • 185