注册 登录
编程论坛 Linux教室

请问下面一段命令文本输出问题答案对吗?

winglesswu 发布于 2013-04-12 22:45, 1868 次点击
cat shapes

#!/bin/bash
for shapes in square triangle circle
do
  if [ "$2" != $shape ]
    then echo "\$2 is not a $shape"
  fi
done

if [ "$1" = "$2" ]
   then echo "Message 1"
     exit 1
fi

if [ $# != 2 ]
  then echo "Message 2"
   exit 2
fi

Q1: shapes square square
$2 is not a triangle
$2 is not a circle
Message 1

Q2: echo $1
1
Q3: shapes circle triangle
$2 is not a triangle //我认为这边的答案应该是$2 is not a square 不知道对不对
$2 is not a circle
0 回复
1