0

I'd like to find all the ".py" file using command:

find / -iregex ".*\.py"

However, it also list '.py` file from the python package such as django.

How could I exclude specified folders in 'grep' command?

AbstProcDo
  • 19,953
  • 19
  • 81
  • 138

2 Answers2

2

You can use the -path option to exclude certain directory paths in your search:

find / -iregex ".*\.py" ! -path "/your/django/directory"

And you can chain this multiple times if you want to exclude multiple directories:

find / -iregex ".*\.py" ! -path "/your/django/directory" ! -path "/another/dir"
moebius
  • 2,061
  • 11
  • 20
1

You can use "grep -v" to invert the selection.

find / -iregex ".*\.py" | grep -v django
M I P
  • 867
  • 10
  • 25