I know I can do this ...
if diff -q $f1 $f2
then
echo "they're the same"
else
echo "they're different"
fi
But what if I want to deny the condition that I am checking? i.e. something like this (which obviously doesn't work)
if not diff -q $f1 $f2
then
echo "they're different"
else
echo "they're the same"
fi
I could do something like this ...
diff -q $f1 $f2
if [[ $? > 0 ]]
then
echo "they're different"
else
echo "they're the same"
fi
Where I check if the exit status of the previous command exceeds 0. But this is a bit inconvenient. Is there a more idiomatic way to do this?
source
share