I have a file as below
cat foo.txt
N N
N N
N N
N N
I-MB I-MB
I want to output those lines which 1st column is not equal 2nd column, so I use awk to implement it
cat foo.txt | awk '$1 != $2'
N N
N N
N N
but very strangely it does not work.
The reason is that it is generated by windows
file foo.txt
foo.txt: ASCII text, with CRLF, LF line terminators
After converting it to unix form it works.
sed -e 's/^M$//' foo.txt > foo2.txt
file foo2.txt
foo2.txt: ASCII text
So why CRLF
could affect some awk functions but other not? e.g.
head foo.txt | awk '$1 !~ /N/'
I-MB I-MB
I-MB I-MB