开发者

How can I automatically open a file if it's the only result in grep?

开发者 https://www.devze.com 2023-01-20 10:22 出处:网络
[meder@kat directoryName]$ grep -RlI \"send you instr\" * application/views/scripts/auth/forgot.phtml [meder@kat directoryName]$
[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开发者_Go百科 somehow pipe it to vim?


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.


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


vim `grep -RlI "send you instr" *`
0

精彩评论

暂无评论...
验证码 换一张
取 消