Skip to content

Instantly share code, notes, and snippets.

@umidjons
Created July 18, 2014 04:55
Show Gist options
  • Save umidjons/d2d0674d59d8c1876a91 to your computer and use it in GitHub Desktop.
Save umidjons/d2d0674d59d8c1876a91 to your computer and use it in GitHub Desktop.
Execute dos2unix for directory recursively.

Will recursively find all files inside current directory and call for these files dos2unix command. Would break if you had spaces in file name.

find . -type f -exec dos2unix {} \;

Wouldn't break if you had spaces in file names.

find . -type f -print0 | xargs -0 dos2unix

Convert only *.php files

find . -type f -name "*.php" -print0 | xargs -0 dos2unix

If it's a large directory you may want to consider running with multiple processors:

find . -type f -print0 | xargs -0 -n 1 -P 4 dos2unix 

This will pass 1 file at a time, and use 4 processors.

@spartan4cs
Copy link

Nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment