Bash "not": inverting the exit status of a command
if ! diff -q "$f1" "$f2"; then ...
If you want to negate, you are looking for !
:
if ! diff -q $f1 $f2; then
echo "they're different"
else
echo "they're the same"
fi
or (simplty reverse the if/else actions) :
if diff -q $f1 $f2; then
echo "they're the same"
else
echo "they're different"
fi
Or also, try doing this using cmp
:
if cmp &>/dev/null $f1 $f2; then
echo "$f1 $f2 are the same"
else
echo >&2 "$f1 $f2 are NOT the same"
fi