您的位置:首页 > 运维架构 > Shell

输入一个暂停的数字,然后从1打印到该数字,然后询问是否继续.继续的话再输入数字 接着打印,不继续退出

2016-03-25 16:56 796 查看
#!/bin/bash
while : ; do
read -p "do you continue(y/n):" k
case $k in
y )
read -p "u input the number:" n
if [ $n -lt 6 ]
then
m=`seq $n 5`
echo $m
elif [ $n -gt 5 ] && [ $n -lt 16 ]
then
m1=`seq $n 15`
echo $m1
fi
continue
;;
n )
exit
;;
* )
echo "你输入错误,请重新输入"
;;
esac
done
fi
#!/bin/bash
kl(){
read -p "input a pause num:" i
read -p "input a pause num:" xi
for((i=$i;i<=$xi;i++))
do
echo -e "$i \c"
done
echo
}

while :
do
read -p "continue?(y|n)" yes
if [ "$yes" = "y" ]
then
kl
else
exit 1
fi
done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell 练习