SEHLL中疑问

老师为什么效果跟您教程中效果不一样呢

————————————————————————代码——————————————————————————————
#!/bin/bash
# "select" "case" usage
echo "a is 5, b is 3. Please select you method:"
a=5
b=3
select var in "a+b" "a-b" "a*b" "a/b"
do
        break
done
case $var in
        "a+b")
        echo 'a+b=''expr $a "+" $b'
        ;;
        "a-b")
        echo 'a-b=''expr $a "-" $b'
        ;;
        "a*b")
        echo 'a*b=''expr $a "*" $b'
        ;;
        "a/b")
        echo 'a/b=''expr $a "/" $b'
        ;;
        *)
        echo "You Enter is error"
esac
————————————————————————————执行后效果——————————————————————————
[root@localhost test]# ./select
a is 5, b is 3. Please select you method:
1) a+b
2) a-b
3) a*b
4) a/b
#? 1
a+b=expr $a "+" $b


-----------------------------------------------------代码-----------------------------------------------------------------------------
#!/bin/sh
#this is back file shell
DATE='/bin/date +%Y%m%d'
/bin/tar -cf /backup/$1.$DATE.tar $1 >/dev/null 2>> /backup/$1.back.log
/bin/gzip /backup/$1.$DATE.tar
if [ $? -eq 0 ]
then
        echo"$1 $DATE backup successfully" >> /backup/$1.back.log
else
        echo"ERROR: failure $1 $DATE backup!" >> /backup/$1.back.log
fi
-----------------------------------------------------执行后结果-------------------------------------------------------------------
[root@localhost test]# ./back.sh /etc
./back.sh: line 4: /backup//etc.back.log: No such file or directory
gzip: /backup//etc./bin/date: No such file or directory
gzip: +%Y%m%d.tar: No such file or directory
./back.sh: line 10: /backup//etc.back.log: No such file or directory


作者: renziyou   发布时间: 2011-10-22

sh -x 来检测脚本执行的过程,帮助你来分析,而且有的脚本执行时本身错误提示已经非常明显,比如你的第二个shell脚本

作者: 李明   发布时间: 2011-10-22