下面是我的bash腳本代碼,用於複製數據,但我在SUBSTRING
行中遇到語法錯誤。我是bash新手,所以無法理解語法的問題。任何幫助表示讚賞。我無法解決此bash腳本中的語法錯誤(版本4.1.2)
#!/bin/bash
cd /var/www/html/zong/public/HostedPBX/
for i in $(echo */); #..This loop shows number of directories in a
folder to display them.....
do
echo /var/www/html/zong/public/HostedPBX/$i
done echo"" echo "Above are the folders listed in current directory..."
sleep 2 echo"" echo "Taking Backup of above folders...."
sleep 3
for i in $(echo /var/www/html/zong/public/HostedPBX/*/);
**SUBSTRING=$(echo $i | cut -d'/' -f 7)
# $SUBSTRING=$(echo $i cut -d'/' -f 7)** ####...this also gives syntax error
do
cp -R $i /root/HostedPBX_Backup/$SUBSTRING ##...Uncommment this line to copy files from HostePBX to HostedPBX_Backup.....
done
請看看[編輯的幫助( http://stackoverflow.com/editing-help)。 – Cyrus
請看看:http://www.shellcheck.net/ – Cyrus