Useful find Commands

Recursive, multi-file find and replace with grep and xargs for performance:


grep -rl 'what_to_find' ./ | xargs sed -i 's/what_to_find/what_to_replace_with/g'

PutĀ  a not in front of that expression:

find ./ ! -type d

Escape wildcards to avoid the shell expanding them:

If you just quote it; “*.avi” you can often run into trouble.

find ./ -name \*.avi

Prune empty directories

find ./ -depth -type d -empty -exec rmdir -v {} \;


One thought on “Useful find Commands

  1. Pingback: Recent Links Tagged With "xargs" - JabberTags

Leave a Reply

Your email address will not be published. Required fields are marked *