Something similar to a sub search #2980
-
Not sure if it's even the right name. I've found #273 but not able to apply it to my use-cases. I'm on Windows using Powershell (no xargs, no WSL, no git-bash, no cygwin) I want to search files for PATTERN1. The result returns the matching filenames which should be the input to the next search for PATTERN2. Something like: What would be a solid way to achieve this in Powershell? A solution in bash would also be of interest for my understanding. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
If you have bash, then you either likely have xargs or can get xargs. And if you have xargs, this is pretty easy: I'm not a powershell user, so I'm not really able to help with that. That's probably a better question for a powershell specific help forum. But beyond #273, I'm unlikely to add any other features here specific to sub searches. ripgrep really is designed to be used in composition with other tools via shell pipelines. |
Beta Was this translation helpful? Give feedback.
-
Thank you for explaining. I also seemed to mix it up a bit mit the --exec arg of fd https://github.com/sharkdp/fd |
Beta Was this translation helpful? Give feedback.
If you have bash, then you either likely have xargs or can get xargs. And if you have xargs, this is pretty easy:
rg PATTERN1 -l -0 | xargs -0 rg PATTERN2
.I'm not a powershell user, so I'm not really able to help with that. That's probably a better question for a powershell specific help forum. But beyond #273, I'm unlikely to add any other features here specific to sub searches. ripgrep really is designed to be used in composition with other tools via shell pipelines.