commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Consider using this cmd when:
1. You are planning to traverse a big directory.
2. There is a subdir you don't want find to decend to. (entirely ignore)
3. You don't want find to decend to any mounted filesystems under this dir.
* The -xdev flag tells find do not go to other filesystems.
* -path ./junk_dir -prune is the pattern to ignore ./junk_dir entirely.
* The rest is the typical search and print.
To ignore multiple subdirs, you can just iterate the pattern, e.g.
find . -path ./junk1 -prune -o -path ./junk2 -prune ...
If you do want to include other filesystems, then remove -xdev flag.
If you want to search files, then change -type d to -type f.
There are 6 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.