Shell编程:怎么实现从1到100的输出
答案:1 悬赏:70 手机版
解决时间 2021-04-01 19:33
- 提问者网友:刺鸟
- 2021-04-01 05:48
Shell编程:怎么实现从1到100的输出
最佳答案
- 五星知识达人网友:过活
- 2021-04-01 06:20
You can write a shell file count.sh like this:
*****************************
#!/bin/sh
num=1
while [ $num -le $1 ]
do
echo $num
num=`expr $num + 1`
done
num=1
while [ $num -le $1 ]
do
echo $num
num=`expr $num + 1`
done
*****************************
$chmod a+rwx count.sh
Then you can run ./count.sh count_num
example: ./count.sh 100
programm will output the number 1~100
*****************************
#!/bin/sh
num=1
while [ $num -le $1 ]
do
echo $num
num=`expr $num + 1`
done
num=1
while [ $num -le $1 ]
do
echo $num
num=`expr $num + 1`
done
*****************************
$chmod a+rwx count.sh
Then you can run ./count.sh count_num
example: ./count.sh 100
programm will output the number 1~100
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯