这是我第一个将我的内容同步到服务器的 bash 脚本。我想将要同步的文件夹作为参数传递。但是,它没有按预期工作。
这是我的脚本(保存为sync.sh):
echo "STARTING SYNCING... PLEASE WAIT!"
var="$1" ;
echo "parameter given is $var"
if [ "$var"=="main" ] || [ "$var"=="all" ] ; then
echo "*** syncing main ***" ;
rsync -Paz /home/chris/project/main/ user@remote_host:webapps/project/main/
fi
if [ "$var"=="system" ] || [ "$var"=="all" ] ; then
echo "*** syncing system ***" ;
rsync -Paz /home/chris/project/system/ user@remote_host:webapps/project/system/
fi
if [ "$var"=="templates" ] || [ "$var"=="all" ] ; then
echo "*** syncing templates ***" ;
rsync -Paz /home/chris/project/templates/ user@remote_host:webapps/project/templates/
fi
这是我的输出:
chris@mint-desktop ~/project/ $ sh ./sync.sh templates
STARTING SYNCING... PLEASE WAIT!
parameter given is templates
*** syncing main ***
^Z
[5]+ Stopped sh ./sync.sh templates
尽管我给出了“模板”作为参数,但它忽略了它。为什么?