22

I've got a list of files that I would like to search for a pattern with ripgrep.

How can this be done?

Chris Stryczynski
  • 5,178
  • 5
  • 40
  • 80

1 Answers1

29

ripgrep accepts file paths as arguments. So just pass your files as arguments:

rg pattern file1 file2 ...

If your list is in a file, with one path per line, then use xargs:

xargs -d '\n' -a list-file rg pattern

Or if it's a list generated from find, then:

find ./ ... -print0 | xargs -0 rg pattern
BurntSushi5
  • 530
  • 5
  • 6