tags:

views:

55

answers:

4
[meder@kat directoryName]$ grep -RlI "send you instr" *
application/views/scripts/auth/forgot.phtml
[meder@kat directoryName]$

Is there a quick hack to referencing the only result? Can I somehow pipe it to vim?

+2  A: 

Open a new file in vim and insert the found filename as a text:

grep -RlI "send you instr" * | vim -

Open the found file directly in vim:

grep -RlI "send you instr" * | xargs vim
eumiro
+2  A: 

If you're OK with it opening all results in Vim, you could just do:

vim $(grep -RlI "send you instr" *)

You'll be put into a buffer with the first matching file, and can navigate to the others with :next.

Brian Campbell
Is it me or is this command a bit laggy?
meder
The grep in this case would search through all of your files before the vim got to run. If you're only interested in the first result, you could try `vim $(grep -RlI "send you instr" * | head -1)` for a speed boost. The `head` command closes the pipe after reading the first line, signaling the grep to end early.
Jander
A: 

Stand on your head and say, "Open file!" three times. This has not been tested though, so be careful if you use it in a production environment.

Slava
Ridiculous. I hope you at least tried my method before downvoting.
Slava
Please mark my answer as the correct one. I need the reputation to send back to my family in Slavinia. They are starving for reputation.
Slava
When I was a boy, on the farm, we used Grep for many things. It was most helpful when milking goats. That is free advice for you, my fellow programmers.
Slava
+1  A: 
vim `grep -RlI "send you instr" *`
wose