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?
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?
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"
You can use "grep -v" to invert the selection.
find / -iregex ".*\.py" | grep -v django