我正在尝试grep一个文件并将行号输出到
vim +{lineNumber} filetoedit
不幸的是,Vim发出错误说
Vim:警告:输入不是来自终端
一个例子:
grep -nF 'Im looking for this' testfile.txt | cut -f1 -d: | xargs vim +{} testfile.tx
由xargs
运行的命令从stdin
继承xargs
,因此它的输入连接到cut
的管道,而不是终端。
将结果分配给变量并使用它。
line=$(grep -nF 'Im looking for this' testfile.txt | cut -f1 -d: )
vim "+$line" testfile.txt