shell编程 select for循环
select语句的用法举例:1.编写select1.sh脚本,内容如下:
#!/bin/bash
echo "What color you want to select?"
select color in "blue" "red" "green" "orange"
do
break
done
if [ $color = "blue" ]
then
echo "$color"
else
echo "other"
fi
2.编写select2.sh脚本,内容如下,执行的时候,向脚本传递参数(例sh select2.sh blue color green )
#!/bin/bash
echo "What color you want to select?"
select color
do
break
done
echo "You select color is $color"
for循环嵌套举例:
1.打印9*9棋盘,脚本如下:
#!/bin/bash
for((i=1;i
页:
[1]