2017-04-10 100 views

回答

1

使用||级联。

diff -q file1 file2 || diff file1 file2 | mail -s "subject" "[email protected]" 

更多信息here

+0

奏效。似乎是比如果那么陈述更好的解决方案。谢谢 – user3508766

+0

你也可以用'cmp'来比较文件,它比'diff -q'更轻便,更便于携带。 – ghoti

+0

做了一些研究,但我不会说cmp更快,来源:http://unix.stackexchange.com/questions/153286/is-cmp-faster-than-diff-q –

0

我能找到这个网络,它的工作很大

command > file 
if [ -s file ] 
then 
    mailx -s "Subject" mailaddress <file.tmp 
fi 
rm file