Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
OneIf you can guarantee that file and directory names won't contain newline characters, one method is to find all files, then use grep to match only the desired results:
find . -type f | grep '/foo/[^/]*$'
One method is to find all files, then use grep to match only the desired results:
find . -type f | grep '/foo/[^/]*$'
If you can guarantee that file and directory names won't contain newline characters, one method is to find all files, then use grep to match only the desired results: