问题描述
来自bash shell,我错过了一个简单的循环循环(对于(...)中的i;执行...完成;)
coming from bash shell, I missed on an easy rolling of loops (for i in (...); do ... done;)
您愿意吗?在cshell中发布典型的一线循环?
Would you post typical one-liners of loops in cshell?
请单行而不是多行
thx
ONE LINERS PLEASE, and not multiple-linesthx
推荐答案
哇,我好几年都没有写 csh
脚本了。但比尔·乔伊(Bill Joy)确实亲自写过它,我想值得做些怀旧的事...
Wow, I haven't written a csh
script in years. But Bill Joy did write it himself, I suppose it's worth some nostalgia effort...
set t=(*)
foreach i ($t)
echo $i >> /tmp/z
end
或仅 foreach i(* )
此循环结构与csh具有 word列表的内置概念很好地配合使用。
This loop structure works well with a built-in concept that csh has of a word list. This is sort-of present in bash but not in vanilla posix shells.
set q=(how now brown cow)
echo $q[2]
foreach
循环巧妙地遍历此数据结构。
The foreach
loop neatly iterates through this data structure.
这篇关于如何在csh shell的命令提示符中使用for循环-寻找合适的衬板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!