Bash: using the result of a diff in a if statement
ls -lR $dir > a
ls -lR $dir > b
DIFF=$(diff a b)
if [ "$DIFF" != "" ]
then
echo "The directory was modified"
fi
if ! diff -q a b &>/dev/null; then
>&2 echo "different"
fi
ls -lR $dir > a
ls -lR $dir > b
DIFF=$(diff a b)
if [ "$DIFF" != "" ]
then
echo "The directory was modified"
fi
if ! diff -q a b &>/dev/null; then
>&2 echo "different"
fi