Complete Linux newbie and need help with command to find filenames, list their respective paths, and then further filter that result set by only the paths that contain a specific substring(s).
For example I have a filename identified as someFile.txt
. This filename can exist in multiple directories:
E.g. /some/directory/path/good/someFile.txt
and /some/directory/path/bad/someFile.txt
Using find I can return a list of all paths containing that file, but I'd like to return ones that only contain 'good' in the path name as well. Whitelisting in this example is preferable as there are many variable path names, but I know the ones containing the term 'good' are acceptable.
This is what I have that works:
$ find . -type f \( -name someFile1.txt -o -name someFile2.txt\)
I've also tried the following to no avail:
$ find . -type f \(-name someFile1.txt -o -name someFile2.txt\) -print0 | xargs -0 grep -rl 'good'
$ find . -type f \(-name someFile.txt .... | xargs -0 grep 'good'
$ find . -type f \(-name someFile.txt .... | xargs -0 egrep 'good|real_good'
xargs
- you just want to know if it's in the path, right?find ... | grep good