I have this line of code that reads a text file line by line.
The text file is sometimes generated by a Windows user, sometimes by a Unix user. Therefore, sometimes I see
\r\n at the end of the line and sometimes I see only
I want my script to be able to deal with both scenarios and reach each line separately regardless of whether the linebreak is
while read -r textFileLines; do ... something ...; done < text_file.txt
This code works with
\n\r (LF CR) at the end of each line, but does NOT work when I have
\r\n at the end of the line!
Create a new text file using
while read -r LINE; do echo "$LINE"; done < /cygdrive/d/test_text.txt
output in Terminal:
first_line second_line third_string
Why isn't the
fourth_output line not shown?