Does anyone know why 'grep' will not recognise a text file that I used this script to split into a series of truncated text file with just 1000 lines from a largerfile:
split -l 1000 -d file.txt file --additional-suffix=.txt, (#file00.txt, file01.txt, file02.txt...file26.txt)
However, when I use 'grep' on the same text file content of 1000 lines that I copy from a larger text file and save as another text file, then 'grep' recognises it and carries out the action that I want?
1 answer
I have the answer:
I opened in notepad and in the bottom right corner it told me the split text file created a windows cr/lf file, whereas the original was a unix lf file, both are UTF-8, so the below script fixed the file and now my grep command works:
awk '{ sub("\r$", ""); print }' windows.txt > unix.txt
Alternate methods to convert windows to unix and vice versa can be found here: https://www.maketecheasier.com/convert-files-from-linux-format-windows/
Log in to answer this question.
This is not reproducible. Please add data examples.
how is it related to bioinformatcs ?