Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by nikbackm on Thursday November 30, 2023 @07:52AM
(#38472855)
One thing I wish ripgrep had is support for AND conditions.
[ Parent
| on HN ]
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by kmarc on Thursday November 30, 2023 @08:10AM
(#38473027)
Maybe I'm missing something but I only use it with AND conditions (usually in the form of 'foo 'bar and it only matches lines with foo AND bar both present)
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by burntsushi on Thursday November 30, 2023 @08:22AM
(#38473151)
A search for `rg -e foo -e bar` will return lines that match either foo or bar. Some lines may have both, but it isn't required.
The standard way to run "AND" queries is through shell pipelines. That is, `rg foo | rg bar` will only print lines containing both. But composition usually comes with costs. The output reverts to the standard grep format and it doesn't interact nicely with contextual options like -C/--context.
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by bhaak on Thursday November 30, 2023 @10:49AM
(#38474953)
As I have overloaded my rg with a customized rg alias, I can't pipe multiple rg calls.
Otherwise it would look like this:
# rg nokogiri | rg linux
<stdin>:11:Gemfile.lock:647: nokogiri (1.15.5-x86_64-linux)
But that is a me problem.The workaround is of course just to pipe into grep instead.
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by burntsushi on Thursday November 30, 2023 @10:56AM
(#38475040)
Or `\rg`, which will use the command directly and skip your alias.
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by bhaak on Thursday November 30, 2023 @05:23PM
(#38480032)
Oh, look at that. Nice.
Still losing the coloring but you can't have everything.
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by adren123 on Friday December 01, 2023 @07:40AM
(#38486039)
If you want to win on both counts (no buggy pipes and coloring), and if you're certain of the order, you can use the following:
rg nokogiri.*linux
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by asicsp on Thursday November 30, 2023 @08:56AM
(#38473552)
If you don't mind using PCRE, you can do it. For example:
rg -P '(?=.*pat1)(?=.*pat2)(?=.*pat3)'
You could create a shell function shortcut if you need to use it often. But yeah, having it as a feature of the tool itself would be nice.
Re:Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift ...
by boyter on Thursday November 30, 2023 @04:23PM
(#38479337)
That’s one of the reasons I made this actually https://github.com/boyter/cs
I wanted and boolean syntax mixed with fzf instant search. It’s not as fast as ripgrep of course but it’s not solving the same problem.