The --exclude option for recursive commands
This is one of those "I thought everyone knew about this." tips. I recently discovered that quite a few people don't know that quite a few GNU/*nix commands that operate recursively have an --exclude
option so you can skip certain directories.
The conversation came up when talking about ctags
- but here are some other commands that have the same:
diff
rsync
tar
grep
du
So, man <the_command>
and look for --exclude
. Many of these programs will also have either an --exclude-from
or allow you to supply an @
prefixed filename to the --exclude
option so you can give a file that contains a list of dirs/paths to exclude.
Watch the specifics of each command, some are quite exotic (especially rsync
), and some have other related options (like grep
has --exclude-dir
)
Written by Jason King
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#