在循环中循环循环时弹壳脚本
使用TCSH,我想为每个X,Y,Z,E和F打印“ Hello”。但是使用以下脚本,它仅打印x。有人可以告诉我如何也为y,z,e和f打印“ Hello”?
#! /bin/tcsh -f
set arr=(x y z e f)
set j = 0
foreach i ($arr)
echo $i
while ($j < 5)
echo "Hello"
@ j++
end
end
结果是:
X
你好
你好
你好
你好
你好
y
Z
E
f
with tcsh, I want to print "Hello" for each x,y, z, e, and f. But with the following script, it only prints x. Can someone tell me how to print "Hello" also for y, z, e, and f?
#! /bin/tcsh -f
set arr=(x y z e f)
set j = 0
foreach i ($arr)
echo $i
while ($j < 5)
echo "Hello"
@ j++
end
end
The result is:
x
Hello
Hello
Hello
Hello
Hello
y
z
e
f
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将“ J”变量的初始化在foreach循环中:
输出:输出:
Move the initialization of the 'j' variable inside the foreach loop:
Output: