in reply to Adding \n (new line) and removing \r in a file
Or, if there is no "\r" at the end -- that is, you're deleting any/all "\r" in the file and adding "\n" at the end, add the "-l" option:perl -i.bak -pe 's/\r(?!\n)/\n/g; tr/\r//d' test.dat
(but that might not do exactly what you want, depending on what OS you're running on)perl -i.bak -lpe 'tr/\r//d' test.dat
|
|---|