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
  • 17,381
  • 14
  • 68
  • 114

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
  • 1,805
  • 8
  • 17
1

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

find / -iregex ".*\.py" | grep -v django
M I P
  • 759
  • 9
  • 24