Skip to content

Instantly share code, notes, and snippets.

@thaihust
Forked from umidjons/dos2unix.md
Created November 2, 2017 01:19
Show Gist options
  • Save thaihust/b71f1174d09e844f943fabd81f5c7e71 to your computer and use it in GitHub Desktop.
Save thaihust/b71f1174d09e844f943fabd81f5c7e71 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.

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