perl -ne "print if /\r/" file.txt #### perl -pe "BEGIN{binmode *STDOUT}" file.txt > file2.txt