phiresky / ripgrep-all

rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.
Other
6.4k stars 148 forks source link

find ebooks that match all the search strings #210

Open blueray453 opened 4 months ago

blueray453 commented 4 months ago

Is your feature request related to a problem? Please describe.

I want to find all files which have the words:

I mean all words have to be present in the file. They do not need to be in the same line, paragraph or page.

Describe the solution you'd like

When I use: rga --word-regexp --sort path --ignore-case --files-with-matches --regexp "A1" --regexp "A2", i think the --regexp work as or. I need a operator that will work as and, something like --and "A1" --and "A2"

Describe alternatives you've considered

I am currently using:

comm -12 <(rga 'A1' --ignore-case --files-with-matches | sort) \
<(rga 'A2' --ignore-case --files-with-matches | sort) \
| comm -12 - <(rga 'A3' --ignore-case --files-with-matches | sort) \
| comm -12 - <(rga 'A4' --ignore-case --files-with-matches | sort)

However, this is not optimal.

geff10 commented 4 months ago

I think maybe it should be in ripgrep itself, or in other wrapper.

By the way, I would be happy to see a similar feature, but for me it would be more practical to filter those findings where both words are in the same line. It is also solvable with some regex magic but it would be handy to simplify this usecase. (I'm considering implementing this feature myself if I cannot find a ready solution.)