私のファイルには、次のようないくつかのコマンドがあります。
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"