运行 Bash 脚本时出现此错误:
语法错误:文件意外结束
无法真正找到错误在哪里,一直在寻找几个小时,仍然得到这个错误。
这是脚本希望有人不能指出我正确的方向:
#!/bin/bash
BACKUPDIR=~/backup
SCRIPTDIR=~/respaldar
BACKUPFILE=/respaldo.$(date +%F).bz2
BACKUPHOST=199.21.112.70
COUNT=$(ls $BACKUPDIR | wc -l)
TRESHOLD=7
if [[ ! -e $BACKUPDIR ]]
then
echo "Creating Backup Directory because it doesn\'t exist !"
mkdir ~/backup
COUNT=0
# exit 0
else
COUNT=$(ls $BACKUPDIR | wc -l)
fi
if [[ $COUNT -le $THRESHOLD ]]
then
tar -cjvf $BACKUPDIR/$BACKUPFILE $SCRIPTDIR
if [[ $? -ne 0 ]]; then echo "Problems Creating Backup File;" fi
scp $BACKUPDIR/$BACKUPFILE $BACKUPHOST:
if [[ $? -ne 0 ]]; then echo "Problems Copying Backup File to Backup Host;" fi
fi
#END
感谢帮助。