Convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix

user1316233 picture user1316233 · May 17, 2012 · Viewed 13.4k times · Source

How do I convert all EOL (dos->unix) of all files in a directory and sub-directories recursively without dos2unix? (I do not have it and cannot install it.)

Is there a way to do it using tr -d '\r' and pipes? If so, how?

Answer

smocking picture smocking · May 17, 2012

For all files in current directory you can do it with a Perl one-liner: perl -pi -e 's/\r\n/\n/g' * (stolen from here)

EDIT: And with a small modification you can do subdirectory recursion:

find | xargs perl -pi -e 's/\r\n/\n/g'