-1

I type

grep -r 'something' .

and grep finds a lot of hits.

Now I want to open all files that were found.

I try

grep -r 'something' . | xargs vim

nothing happens.

Duck
  • 34,902
  • 47
  • 248
  • 470

2 Answers2

0

Maybe this ?! :)

grep -rl 'something' . | xargs vim

or

vim "$(grep -rl 'something' .)"

-l, --files-with-matches
Suppress normal output; instead print the name of each input file from which output would normally have been printed. Scanning each input file stops upon first match.

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
0

Assuming there are no special characters in your files (like newlines), try this:

grep -lr 'something' . | xargs bash -c 'vim "$@" < /dev/tty' _
Philippe
  • 20,025
  • 2
  • 23
  • 32