“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” 😉

Comments are closed.

Niklas Tech Blog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.