Tengo algunos comandos en un archivo que son como
diff file1 file2
diff file3 file4
Y si sale algo, quiero imprimir en qué comando sucedió esto, como por ejemplo
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
Respuesta1
El comando diff sale con 1
si hay una diferencia. La forma más sencilla lo utiliza como verificación de éxito/fracaso:
diff file1 file2 || print "file1 and file2 had the difference"
diff file3 file4 || print "file3 and file4 had the difference"