Terry Martin
Terry Martin

Reputation: 579

How do I find all files above a certain size while ignoring certain directories (using a bash script)

so I'm trying to use bash to find all files above 500MB. I have been able to accomplish this using find ~ size +500M.
However, the output contains a lot of python library files that aren't relevant to my search. So how do I adjust this command (using bash or grep or awk) so that it excludes certain directories (for example /webapps/lib/python2.7/) Thanks for the help in advance, everyone.

Upvotes: 1

Views: 1555

Answers (2)

Amit
Amit

Reputation: 20456

You can use path with negation. For example, the following command will exclude results whose path start with "~/path1" or "~/path2"

find ~ size +500M ! -path "~/path1/*" ! -path "~/path2/*"

Upvotes: 1

karakfa
karakfa

Reputation: 67507

find . -path /webapps/lib/python2.7 -prune -o -size +500M

Upvotes: 2

Related Questions