Shell编程:怎么实现从1到100的输出
1个回答
展开全部
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询