SWAT Blog

Convert CRLF to LF line endings recursively

January 20th, 2012 by Atul Sharma

dos2unix utility converts a file from dos to unix format, i.e replaces CRLF line endings to LF line endings.

This utility can be installed on any *nix environment using apt, yum, ports, etc.

To install on Mac:

sudo port -d selfupdate
sudo port install dos2unix

To install on Debian/Ubuntu/Mint:

apt-get install dos2unix

To run this utility recursively in a directory (excluding subdirectories) cd to the directory and then run following command:

find . -name *.* -exec dos2unix {} ;

To run this utility recursively (including subdirectories) cd to the directory and then run following command:

for file in `find . -type f`; do dos2unix $file $file; done

Tags:

Leave a Reply for Anonymous

  • © 2004-2015 Special Work & Technology Limited