标签:ber shell 脚本 inpu ase please input log logs class
写一个 shell 脚本,提示你输入一个暂停的数字,然后从 1 打印到该数字,然后询问是否继续,继续的话在输入个在数字接着打印,不继续退出。
例:如果输入的是 5,打印 1 2 3 4 5 然后继续输入 15 然后打印 6 7 ...14 15 依此类推。
#!/bin/bash read -p "Please input a number: " num1 seq 1 $num1 read -p "Do you want to continue?(y/n): " chose if [ $chose == ‘n‘ ] then exit 1 else read -p "Please input a number: " num2 if [ $num1 -ge $num2 ];then echo "请输入比之前大的数" read -p "Please input a number: " num2 fi seq $[num1+1] $num2 num1=$num2 read -p "Do you want to continue?(y/n): " chose fi
标签:ber shell 脚本 inpu ase please input log logs class
原文地址:http://www.cnblogs.com/pzk7788/p/7550936.html