a strange mistake in the file rm duplicate

The newline character in Windows is \r\n, and in Linux is \n. Linux cannot recognize the \r identifier and will treat it as part of the text content.

You can use dos2unix to convert it permanently (dos2unix list.txt) or you could do it on the fly by setting IFS=$'\r':


while IFS=$'\r' read -r filename || [[ $filename ]]
    echo "do something with $filename"
done < list.txt

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top