The shell history is a great resource. I felt a bit lost when I was up to a "find" task on a freshly setup server without the mighty power of my shell history...
Back in my familiar surroundings I decided to browse the history...
cat ~/.zsh_history| grep find
and put together some of my favorite "find" one-liners.
Find all files starting with devops or Devops:
find . -name '[Dd]evops.*'
Find files with name pattern '*.html' that contain the word devop and print filename and line number:
find . -type f -name "*html" -exec grep -H -n 'devop' {} \;
Find a directory with the name mongodb-backup:
find . -type d -name "mongodb-backup"
Clean up a CVS or svn working copy:
find . -name .svn -exec rm -rf {} \;
find . -name CVS -exec rm -r {} \; 2> /dev/null
Or use "find" in combination with "xargs":
find /var/spool/hourlyLog -type f -print0 | xargs -0 rm
find . -name '*foobar*' -print0 | xargs -0 rm
Run the git alias 'git datenkollektiv' in the submodules folders only:
find . -maxdepth 1 -type d -name "[a-z]*" -exec cd {} \&\& git datenkollektiv \&\& cd .. \;
Replace all php-short tags within '*.php' with long tags using Perl (cudos go to my former colleague settel ;-)
find . -name '*.php' | while read f ; do <"$f" perl -pe 's/<\?(\s|$)/<?php$1/xg;' >tmp ; mv tmp "$f"; done