写一个shell脚本。提示你输入一个暂停的数字,然后从1打印到该数字。然后询问是否继续。继续的话在输入个在数字 接着打印。不继续退出。
例:如果输入的是5,打印1 2 3 4 5 然后继续 输入15 然后打印 6 7 ...14 15 以此类推。
{{{密码回复可见}}}
例:如果输入的是5,打印1 2 3 4 5 然后继续 输入15 然后打印 6 7 ...14 15 以此类推。
{{{密码回复可见}}}
0
本帖最后由 wsw13640218682 于 2016-3-25 16:10 编辑
- 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
0
- #!/bin/bash
- # Author: Maria.
- # Date & Time: 2016-03-25 15:18:05
- # Description: Please Edit here.
- dayin(){
- for((i=$i;i<=$sz;i++))
- do
- echo -e "$i \c"
- done
- echo
- }
- i=1
- read -p "input a pause num:" sz
- dayin
- input(){
- read -p "input a pause num:" sz
- dayin
- }
- while :
- do
- read -p "continue?(y|n)" yes
- if [ "$yes" = "y" ]
- then
- input
- else
- exit 1
- fi
- done
0
easy
#!/bin/bash
read -p "please enter a number:" n
for i in `seq 1 $n`
do
echo $i
done
while :
do
echo "continue or not "
read -p "if not,please enter quit ,else enter a number than $n:" t
if [ "$t" = "quit" ]
then
exit
else
m=$t
for i in `seq $n $m`
do
echo $i
n=$m
done
fi
done
#!/bin/bash
read -p "please enter a number:" n
for i in `seq 1 $n`
do
echo $i
done
while :
do
echo "continue or not "
read -p "if not,please enter quit ,else enter a number than $n:" t
if [ "$t" = "quit" ]
then
exit
else
m=$t
for i in `seq $n $m`
do
echo $i
n=$m
done
fi
done
0
#!bin/bash
i=1
while:;do
read -p "please input a number: " a
for i in ` i -lt a`
$i=$i+1
echo $i;
done
read -p "Whether or not to continue: " b
if [$b -eq yes];
then
continue
else
exit
fi
i=1
while:;do
read -p "please input a number: " a
for i in ` i -lt a`
$i=$i+1
echo $i;
done
read -p "Whether or not to continue: " b
if [$b -eq yes];
then
continue
else
exit
fi
0
#! /bin/bash
read -p "请输入一个暂停的数字: " x
for i in `seq 1 $x`;do
echo $i
done
while :;do
read -p "想要继续吗 ?继续的话请输入另外一个数字: " x
for i in `seq $x+1 $n`;do
echo $i
done
done
read -p "请输入一个暂停的数字: " x
for i in `seq 1 $x`;do
echo $i
done
while :;do
read -p "想要继续吗 ?继续的话请输入另外一个数字: " x
for i in `seq $x+1 $n`;do
echo $i
done
done
0
#!/bin/bash
read -p "please enter a number:" n
m=1
while [ $n != 'q' ]
do
for i in `seq $m $n`
do
echo $i
done
m=$(($n+1))
read -p "please enter a number:" n
done
read -p "please enter a number:" n
m=1
while [ $n != 'q' ]
do
for i in `seq $m $n`
do
echo $i
done
m=$(($n+1))
read -p "please enter a number:" n
done
编辑回复