由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - shell script for "for" loop
相关主题
为什么我就是不会写Shell script?One shell question
[转载] a question about shell script怎么从script中把环境变量传回到当前shell中? (转载)
shell script questionbash programming problem on string
求助一个shell scripthow to change login shell?
shell programming[转载] About the history
[转载] Re: shell script questionwhere can find source code of Bash or csh or any shell
which shell is best?Re: 想登录后的shell是bash
help shell script (waiting on line)How to program? Shell Question
相关话题的讨论汇总
话题: loop话题: script话题: shell话题: do话题: ksh
进入Unix版参与讨论
1 (共1页)
b***l
发帖数: 15
1
In this script:
for i in 1 2 3 4; do echo $i; done
It will print 1 2 3 4. But if I want to loop from 1 to N which is very large,
e.g, 100000, how to do that in bash or ksh using "for" loop? Is there anything
like "for i in 1:10000"? This one does not work.
3x
f********h
发帖数: 149
2
you can increase i by i=`expr $i + 1`

【在 b***l 的大作中提到】
: In this script:
: for i in 1 2 3 4; do echo $i; done
: It will print 1 2 3 4. But if I want to loop from 1 to N which is very large,
: e.g, 100000, how to do that in bash or ksh using "for" loop? Is there anything
: like "for i in 1:10000"? This one does not work.
: 3x

b***l
发帖数: 15
3
I used this approach in a while loop to do the same thing. But I am wondering
if there is a short cut other than this way.
Thanks any way.

large,
anything

【在 f********h 的大作中提到】
: you can increase i by i=`expr $i + 1`
c*****t
发帖数: 1879
4
nope. That was the standard approach :)

【在 b***l 的大作中提到】
: I used this approach in a while loop to do the same thing. But I am wondering
: if there is a short cut other than this way.
: Thanks any way.
:
: large,
: anything

1 (共1页)
进入Unix版参与讨论
相关主题
How to program? Shell Questionshell programming
我的cxterm比较怪[转载] Re: shell script question
which shell is the best among csh, ksh, bsh?which shell is best?
[转载] 简单问题 -- about shell scripthelp shell script (waiting on line)
为什么我就是不会写Shell script?One shell question
[转载] a question about shell script怎么从script中把环境变量传回到当前shell中? (转载)
shell script questionbash programming problem on string
求助一个shell scripthow to change login shell?
相关话题的讨论汇总
话题: loop话题: script话题: shell话题: do话题: ksh