seidenkaufman · 2022-06-13 15:35
From the command line, I can get `grep` to use the lines in a file to search through another file by using the `-f` flag. For example, `grep -f file1 file2`
In Emacs, is there a way to use `grep` such that the contents of a buffer (not necessarily saved to file) would be used in the same way as `file1` in the command above?
Thank you!
_viz_ · 2022-06-13 15:50
Use occur or multi-occur instead. The former is bound to M-s o.
ambihelical · 2022-06-13 15:52
You can use shell-command-on-region (M-|) along with using - (single hyphen) as the file name given to grep. So you would type:
M-| grep -f- file-to-grep
seidenkaufman · 2022-06-13 16:53
Thanks, this worked brilliantly!
dpoggio · 2022-06-14 02:46
This is what I would use. You can even use multiple regexes and keep seeing the outcome as you type. Neat.