我试过这个,
#!/bin/ksh for i in {1..10} do echo "Welcome $i times" done在AIX框的Ksh中。 我得到的输出为,
欢迎{1..10}次
这有什么不对? 不应该从1到10打印吗? 编辑:根据perkolator的帖子,从迭代到ksh中的一系列整数?
它只适用于Linux。 unix box ksh还有其他工作/替换吗?
for i in 1 2 3 4 5 6 7 8 9 10很难看
谢谢。
I tried this,
#!/bin/ksh for i in {1..10} do echo "Welcome $i times" donein Ksh of an AIX box. I am getting the output as,
Welcome {1..10} times
What's wrong here? Isn't it supposed to print from 1 to 10?. Edit: According to perkolator's post, from Iterating through a range of ints in ksh?
It works only on linux. Is there any other work around/replacements for unix box ksh?
for i in 1 2 3 4 5 6 7 8 9 10is ugly.
Thanks.
最满意答案
我认为从内存ksh ,AIX上的标准ksh是一个较旧的变种。 它可能不支持ranged for循环。 尝试使用ksh93而不是ksh运行它。 这应该与ksh在同一个地方,可能是/usr/bin 。
否则,只需使用旧式的东西:
i=1 while [[ $i -le 10 ]] ; do echo "Welcome $i times" i=$(expr $i + 1) done实际上,通过publib查看似乎证实了这一点( ksh93片段),所以我试着沿着那条路走下去。
I think from memory that the standard ksh on AIX is an older variant. It may not support the ranged for loop. Try to run it with ksh93 instead of ksh. This should be in the same place as ksh, probably /usr/bin.
Otherwise, just use something old-school like:
i=1 while [[ $i -le 10 ]] ; do echo "Welcome $i times" i=$(expr $i + 1) doneActually, looking through publib seems to confirm this (the ksh93 snippet) so I'd try to go down that route.
更多推荐
发布评论