请问如下脚本错在哪里?搞了老半天了。

请问如下脚本错在哪里?搞了老半天了。请老大们指点!
脚本内容:
#!/bin/bash
ip=$1
if [ -s /tmp/a.txt ];then
case "$ip" in
"10.10.1.1")
  echo "IPaddress is 10.10.1.1" >> a.txt
  ;;
case "$ip" in
"10.10.2.1")
  echo "IPaddress is 10.10.2.1" >> a.txt
;;
esac
fi
exit


执行结果:
[root@RHEL54 tmp]# sh -x test.sh "10.10.2.1"
+ ip=10.10.2.1
test.sh: line 8: syntax error near unexpected token `"$ip"'
test.sh: line 8: `case "$ip" in '
[root@RHEL54 tmp]# sh -x test.sh "10.10.1.1"
+ ip=10.10.1.1
test.sh: line 8: syntax error near unexpected token `"$ip"'
test.sh: line 8: `case "$ip" in '
[root@RHEL54 tmp]#

作者: anderlee   发布时间: 2011-03-02

case语法不对
case "$ip" in
"10.10.1.1")
  echo "IPaddress is 10.10.1.1" >> a.txt
  ;;
"10.10.2.1")
  echo "IPaddress is 10.10.2.1" >> a.txt
;;
esac
即可

作者: jy02107028   发布时间: 2011-03-02