Getting -nan in output of awk statement
I have 2 files that are created by other processes where I need to divide the value of one file by the value of the other.
I am currently using the following command: paste file1.txt file2.txt | | awk '{print $2/$1};' > file3.txt I am getting the correct output but I am also getting a second line that contains -nan. So if file1.txt = 10 and file2.txt = 50 I am getting the following output: 5 -nan I am very much a newbie to Linux and I am trying to use it for some file manipulation I simply cannot do in Windows. I apologize if my question seems basic. I am guessing the -nan has something to do with the fact I am dividing but I have no idea and haven't found anything yet in my searches. Thanks |
With the input files as described and the command shown (less the second |) I cannot reproduce the problem:
Code:
c@CW8:/tmp$ paste file1.txt file2.txt | awk '{print $2/$1};' |
"nan" almost certainly means "not a number". Check for the presence of a blank line at the end of either input file.
|
Getting -nan in output of awk statement
rk worked perfectly. There was a linefeed inserted immediately following the integer within the file. Using vi I edited the 2 originals to be sure and it worked. I then found where it got inserted in the workflow previous to my current script.
Issue solved! |
All times are GMT -5. The time now is 10:41 PM. |