Eu tenho alguns comandos em um arquivo que são como
diff file1 file2
diff file3 file4
E se alguma coisa for exibida, quero imprimir em qual comando isso aconteceu, como
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
Responder1
O comando diff sai com 1
se houver uma diferença. A maneira mais fácil usa isso como uma verificação de sucesso/falha:
diff file1 file2 || print "file1 and file2 had the difference"
diff file3 file4 || print "file3 and file4 had the difference"