Я получаю синтаксическую ошибку, используя diff в bash. Вот сценарий. часть в Bold - то, где у меня есть проблемы.
#!/bin/bash
FILES="/var/www/html/*";
varPath="/var/log/wwwHash";
tmpPath="/tmp/wwwHash";
if [[ -f $varPath ]];
then mv $varPath $tmpPath;
fi
touch $varPath;
for f in $FILES ;
do if [[ ! -d $f ]];
then md5sum -t $f >> /var/log/wwwHash;
fi ;
done;
if [[ `diff $varPath $tmpPath | wc -c` -lt 2 ]];
then echo "The files in the WWW/html folder have not changed";
else
echo "The files in the WWW/html folder have changed."
echo "The following are the files that have changed:"
# Output which file has changed
diff $varPath $tmpPath;
fi
В частности, эта часть вызывает синтаксическую ошибку.
if [[ `diff $varPath $tmpPath | wc -c` -lt 2 ]];
then echo "The files in the WWW/html folder have not changed";
else
echo "The files in the WWW/html folder have changed."
echo "The following are the files that have changed:"
# Output which file has changed
diff $varPath $tmpPath;
fi