I often grep a bunch of files to find a line, and then grep returns one result. Rather than copying and pasting the filename into a new command, I'd like to be able to open that one result with an editor. Something like: grep foo | vim
. Is there a way to do that in BASH?
Bash – How to Open a File Resulting from Grep
bashgrep
Best Answer
Use
grep -l
to just get the filename of the matching file and not the matching text, then combine it withvim
: