Q:

Any format to UNIX end line format recursively

I have two different script to change DOS2UNIX and MAC2UNIX endline format
DOS2UNIX: perl -pi -e 's/\r\n/\n/;' < dos1.txt > dos2.txt
MAC2UNIX: perl -p -e 's/\r/\n/g' < mac1.txt > mac2.txt
Is there anyway get these functionalities in a signle command to change EOL UNIX format!
Thanks

A:

This handles both cases.
perl -pe 's/\r\n?/\n/g'

It (semi-obviously) does the wrong thing if you have a DOS file with a bare CR somewhere within a line, which should (perhaps) not be converted to LF.

