我的文件中有一些类似的命令
diff file1 file2
diff file3 file4
如果有任何输出,我想打印发生在哪个命令中,例如
diff file1 file2
if (there was output from the diff command)
print "file1 and file2 had the difference"
endif
diff file3 file4
if (there was output from the diff command)
print "file3 and file4 had the difference"
endif
答案1
1
如果存在差异,diff 命令将退出。最简单的方法是使用它作为成功/失败检查:
diff file1 file2 || print "file1 and file2 had the difference"
diff file3 file4 || print "file3 and file4 had the difference"