Load the result of an egrep inside an editor (vim/emacs/gedit)
Question
I got some files, after an egrep command, like
egrep -l -r '(this|that|those)' *
This will list about 20 files. I don't want to open each one manually, is there any way to redirect the result from grep
, directly to an editor so the editor will open those files to me?
Solution
egrep -l 'pattern' * | xargs $EDITOR
$EDITOR
should be set to your editor of choice, obviously.
OTOH said editor probably has a shorter, non-caps name, so you'd just type it directly.
Me, I'm all day doing this:
ack --ruby -l 'pattern' | xargs mate
(Also take the tip that ack
is way cooler1 than egrep
and does recursive file matching by default, with filters per file type)
1 Where by cooler I mean real perl
regular expressions.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow