Bash"not":反转命令的退出状态

Coq*_*cot 6 bash conditional

我知道我能做到这一点......

if diff -q $f1 $f2
then
    echo "they're the same"
else
    echo "they're different"
fi
Run Code Online (Sandbox Code Playgroud)

但是,如果我想否定我正在检查的条件呢?即这样的事情(显然不起作用)

if not diff -q $f1 $f2
then
    echo "they're different"
else
    echo "they're the same"
fi
Run Code Online (Sandbox Code Playgroud)

我可以这样做......

diff -q $f1 $f2
if [[ $? > 0 ]]
then
    echo "they're different"
else
    echo "they're the same"
fi
Run Code Online (Sandbox Code Playgroud)

我在哪里检查前一个命令的退出状态是否大于0.但这感​​觉有点尴尬.有没有比较惯用的方法呢?

Wil*_*ell 9

if ! diff -q $f1 $f2; then ...
Run Code Online (Sandbox Code Playgroud)