“dos2unix” function for multiple files using Perl

Changing line endings from DOS to UINX for a single file is easily done with the dos2unix command in most *NIX systems. Doing the same on a whole folder of files is however a little more tricky. To solve that problem I stumbled across this solution made in Perl:

perl -pi -e 's/\cM$//' *

Just run it from inside the folder which files you want to convert and “Bob’s your Uncle” 😉

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>