我正在使用grep -e Peugeot -e PeuGeot carlist.txt
carlist.txt 搜索并提取一些项目,我认为这grep -e Peugeot -e PeuGeot carlist.txt | vi
会为我通过管道,但这就是我得到的:
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
Run Code Online (Sandbox Code Playgroud)
Pet*_*zel 126
使用“-”作为参数运行 vi 或 vim 使其从标准输入读取文件以进行编辑。因此:
grep -e Peugeot -e PeuGeot carlist.txt | vi -
Run Code Online (Sandbox Code Playgroud)
会做你需要的。
ken*_*orb 16
除了vim -
,您还可以使用以下<(command)
语法使用进程替换,例如:
vim <(echo This is example.)
vim <(cat /etc/hosts)
Run Code Online (Sandbox Code Playgroud)
也可以看看:
Jos*_* R. 11
您应该使用输出重定向:
grep ... > newfile.txt && vi newfile.txt
Run Code Online (Sandbox Code Playgroud)
另外,我认为您grep
可以改进:
grep 'Peu[gG]eot' carlist.txt > newfile.txt && vi newfile.txt
Run Code Online (Sandbox Code Playgroud)
输出重定向也可以这样使用:
vi <(grep ...)
Run Code Online (Sandbox Code Playgroud)
甚至可以重定向多个命令输出,就好像它们被保存在单独的文件中一样:
vim -d <(ls) <(ls -a)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
69426 次 |
最近记录: |