我正在尝试使用diff来比较两个文件夹,并针对shell脚本中的每个差异启动vimdiff
这是我使用喜欢执行的awk提取文件名并完成命令的方式
$ diff -Bbqr oldfolder newfolder | grep differ | awk '{print "vimdiff " $2,$4}'
vimdiff oldfolder/a.c newfolder/a.c
vimdiff oldfolder/b.c newfolder/b.c
现在我尝试了
diff -Bbqr oldfolder newfolder | grep differ | awk '{print "vimdiff " $2,$4}' | bash
它不起作用,警告Vim: Warning: Input is not from a terminal
还尝试了bash -c
,如下所示
diff -Bbqr oldfolder newfolder | grep differ | awk '{print "vimdiff " $2,$4}' | bash -c
但这会导致错误bash: -c: option requires an argument
我也尝试过
$(diff -Bbqr oldfolder newfolder | grep differ | awk '{print "vimdiff " $2,$4}')
它根本不输出。
这对任何开发人员都非常有用,所以我希望找到答案
答案 0 :(得分:1)
只是出于好奇,尝试了一下。
这样吧:
vimdiff $(diff -Bbqr oldfolder newfolder | grep differ | awk '{print $2,$4}')
但这对我有用:
$(echo vimdiff file1 file2)
您也可以尝试以下方法:
</dev/tty $(diff -Bbqr oldfolder newfolder | grep differ | awk '{print "vimdiff " $2,$4}')
哦,对了,这个:
bash <(diff -Bbqr oldfolder newfolder | grep differ | awk '{print "vimdiff " $2,$4}')
您也可以这样提出问题:
如何进行这项工作?:
echo vimdiff oldfolder/a.c newfolder/a.c|bash
echo vimdiff oldfolder/a.c newfolder/a.c|bash -c