How to search only files that have a particular directory name anywhere in the path? #1829
Answered
by
learnbyexample
learnbyexample
asked this question in
Q&A
-
Sample file structure:
How do I search only paths that have # globstar is enabled, so this gives the directories I want to search
$ ls -d **/baz/
abc/ijk/baz/ baz/ foo/baz/
# no match
$ rg --files -g '**/baz/'
# only one match
$ rg --files -g '*/baz/*'
foo/baz/f2.txt
# only two matches, abc/ijk/baz/qq/f3.txt is missing
$ rg --files -g '**/baz/*'
foo/baz/f2.txt
baz/f4.txt |
Beta Was this translation helpful? Give feedback.
Answered by
learnbyexample
Mar 19, 2021
Replies: 1 comment 1 reply
-
Well, as is the case often, I just tried this after posting the question: $ rg --files -g '**/baz/**'
foo/baz/f2.txt
abc/ijk/baz/qq/f3.txt
baz/f4.txt Is this the correct way to do this? |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
BurntSushi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, as is the case often, I just tried this after posting the question:
$ rg --files -g '**/baz/**' foo/baz/f2.txt abc/ijk/baz/qq/f3.txt baz/f4.txt
Is this the correct way to do this?