Skip to content

how do I search for multiple patterns? #2586

Answered by BurntSushi
xfzv asked this question in Q&A
Discussion options

You must be logged in to vote

Well there's your problem. The pattern you've provided to ripgrep contains a \n. It looks like GNU grep treats that \n as delimiting multiple patterns. ripgrep has different behavior. Instead it tells you that you can't search for \n in a pattern unless multi-line mode is enabled. So by enabling multi-line mode, you're now searching for the entire pattern including the \n. Just use the -f/--file flag instead:

$ rg -f <(fd --min-depth 2 --max-depth 2 -g "*-9999*" "./var/db/pkg" | cut -d "/" -f 5-6 | sed 's/-9999*//g') test.txt
1:app-portage/eix:0
2:x11-wm/awesome:0

It also works with grep.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@BurntSushi
Comment options

Answer selected by BurntSushi
@xfzv
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants