grep seems to take a file that is terminated by a CRLF and just makes it a LF. My input file and the header file I create both have CRLF. But the output file of my grep command is just a LF. Anyone know why it does this. Makes no sense to me.
Well I tried piping the grep output to sed to see if I could put the Carriage Return back in.
I tried two different ways based on what I read on this website. http://sed.sourceforge.net/sed1line.txt
Neither of them worked.
head -q -n1 input.txt > header.txt
grep -v -f header.txt input.txt | sed "s/$//" >> newfile.txt
and
head -q -n1 input.txt > header.txt
grep -v -f header.txt input.txt | sed -n p >> newfile.txt
I suppose I could just unix2dos the file but that doesn't seem to explain why grep does what it does.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
grep seems to take a file that is terminated by a CRLF and just makes it a LF. My input file and the header file I create both have CRLF. But the output file of my grep command is just a LF. Anyone know why it does this. Makes no sense to me.
Code I am using:
head -q -n1 input.txt > header.txt
grep -v -f header.txt input.txt >> newfile.txt
Well I tried piping the grep output to sed to see if I could put the Carriage Return back in.
I tried two different ways based on what I read on this website.
http://sed.sourceforge.net/sed1line.txt
Neither of them worked.
head -q -n1 input.txt > header.txt
grep -v -f header.txt input.txt | sed "s/$//" >> newfile.txt
and
head -q -n1 input.txt > header.txt
grep -v -f header.txt input.txt | sed -n p >> newfile.txt
I suppose I could just unix2dos the file but that doesn't seem to explain why grep does what it does.
I piped it to gawk 1 and it changed the line back to a CRLF.