Skip to content

Instantly share code, notes, and snippets.

@syahrasi
Forked from umidjons/dos2unix.md
Created January 17, 2017 04:14
Show Gist options
  • Save syahrasi/72d7312cbd299c5420eee029dfa4ce96 to your computer and use it in GitHub Desktop.
Save syahrasi/72d7312cbd299c5420eee029dfa4ce96 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