// you’re reading...

dot.help Lab

Useful find Commands

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

Source: http://www.jonasblog.com/2006/05/search-and-replace-in-all-files-within-a-directory-recursively.html

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 {} \;

Source: http://duramecho.com/ComputerPrograms/DeleteEmptyDirectories/index.html

Discussion

One comment for “Useful find Commands”

  1. [...] public links >> xargs Useful find Commands Saved by lluisbw on Sat 25-10-2008 xargs tip of the day Saved by john32mac on Sun 19-10-2008 [...]

    Posted by Recent Links Tagged With "xargs" - JabberTags | October 26, 2008, 8:49 am

Post a comment

Advertisement

Categories