我知道我可以做到这一点...
if diff -q $f1 $f2
then
echo "they're the same"
else
echo "they're different"
fi
但是如果我想否定我正在检查的条件怎么办?即类似这样的东西(这显然不起作用)
if not diff -q $f1 $f2
then
echo "they're different"
else
echo "they're the same"
fi
我可以做这样的事情......
diff -q $f1 $f2
if [[ $? > 0 ]]
then
echo "they're different"
else
echo "they're the same"
fi
在这里我检查上一个命令的退出状态是否大于0。但这感觉有点尴尬。有没有更惯用的方法来做到这一点?