How can I match ~/.bash* files but exclude ~/.bash_history? #2557
-
Question (TL;DR version)Is there a way for a RipGrep glob filter ( Simple ExampleWhen I couple a $ rg -c -g'!exclude_me.txt' 'text' ./exclude_me.txt ./include_me.txt
./exclude_me.txt:2
./include_me.txt:3 While the above example explicitly lists $ rg -c -g'!exclude_me.txt' 'text' ./*.txt Deeper DiveMy $HOME directory contains several files (and one directory) starting with "
I would like to search through all these except # 1 (the
What Is the Right Way To Do This?Should I simply be passing in different options, or am I using the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As an addendum to the above: the suggestion to filter these results via |
Beta Was this translation helpful? Give feedback.
-
No. This is by design. The driving design point here is that if you tell ripgrep to search a specific file, then it will absolutely do so regardless of any other flags. ripgrep doesn't know about shell globbing as that's expanded before ripgrep itself is invoked. So there is no way for ripgrep to tell the difference between "explicitly specified file" and "file that matched a shell glob." If I were in your situation, I'd probably just specify the files you want to search explicitly since the list is small:
And then put that in an alias or a wrapper script if you do it frequently. Otherwise, you can always do things a bit more explicitly with
Or to be pedantically correct:
|
Beta Was this translation helpful? Give feedback.
No. This is by design. The driving design point here is that if you tell ripgrep to search a specific file, then it will absolutely do so regardless of any other flags. ripgrep doesn't know about shell globbing as that's expanded before ripgrep itself is invoked. So there is no way for ripgrep to tell the difference between "explicitly specified file" and "file that matched a shell glob."
If I were in your situation, I'd probably just specify the files you want to search explicitly since the list is small: