Saturday, November 3, 2007

dos2unix and recursion using bash

More a 'don't ever forget this line again' command for me, but a handy one-liner for a box that has find and dos2unix -- but not a perl interpreter.

find . -type f \( -iname '*.css' -o -iname '*.html' \) \! -path "*images*" -exec dos2unix {} \;

  • Finds all files with a .css or .html extension, starting from the current working directory.
  • Ignores anything in a directory including the word images.
  • Then executes dos2unix on anything that matches.
Of course, you could execute anything (just change dos2unix to whatever you need to run).