Single glob pattern for filename and path #3191
-
|
Hello, I'm trying to find a glob pattern which allow me to consider filepath and filenames at the same time. I was able to find a solution by providing 2 globs pattern, but I was wondering if there was not a way to find with a single glob pattern ? Here is a small example (I'm trying to consider all files/path which contains the string $ mkdir -p baz/ footestfoo/
$ touch bartestbar.bar footestfoo/foo.foo baz/test.baz
$ tree
.
├── bartestbar.bar
├── baz
│ └── test.baz
└── footestfoo
└── foo.foo
2 directories, 3 files
$ rg --files
baz/test.baz
bartestbar.bar
footestfoo/foo.foo
$ rg --glob "*test*" --files
baz/test.baz
bartestbar.bar
$ rg --glob "**/*test*/**" --files
footestfoo/foo.foo
$ rg --glob "**/*test*/**" --glob "*test*" --files
bartestbar.bar
footestfoo/foo.foo
baz/test.bazSo Thanks! (I tried to find any similar question in the gh discussions but couldn't find anything. Moreover, sorry if this is not the place to ask for this, since it's more a "glob" question than a ripgrep's one). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I think you need two globs unfortunately. The reason why And the reason why ripgrep/crates/ignore/src/gitignore.rs Lines 509 to 514 in f09b55b IMO, this isn't really a great experience. I'm not quite sure how to fix this. It's possible that the |
Beta Was this translation helpful? Give feedback.
I think you need two globs unfortunately.
The reason why
*test*doesn't work is because it doesn't match the basename offootestfoo/foo.foo. That's consistent with GNU grep:And the reason why
**/*test*/**doesn't work is that a/**suffix implies that the glob should match only the things inside a directory:ripgrep/crates/ignore/src/gitignore.rs
Lines 509 to 514 in f09b55b