Regular Expression: omit search string
-
11-12-2019 - |
Question
Let's say I'd like to find something specific on a filesystem, but to omit certain directories in the search.
Rather than type locate string
, I'd like to type locate string[omit anything which resides in specified directory]
.
So, for example, let's say I want to omit /usr/share
from the listing.
How is this accomplished?
Solution
locate string | grep -v ^/usr/share
Or, if you search with find
, use -prune
:
find / -name \*string\* \( -path '/usr/share' -prune -o -print \)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow