我正在努力弄清楚如何在tcsh中重复一个复杂的命令,如下所示
repeat 9999 (curl http://localhost:80/index.php; echo)这里我使用的是子subshell,而不是{和},因为根据http://hyperpolyglot.org/unix-shells,tcsh没有这个特性。
但是,我从前面的构造中得到了以下意外错误。
Badly placed ()'s那么,如何用tcsh重复一个复杂的命令呢?
关于csh和tcsh的奇怪的不一致,有一些老生常谈,比如这个http://www.grymoire.com/unix/CshTop10.txt。所以我不知道该如何看待这个错误。
发布于 2016-04-13 21:09:20
来自tcsh(1):
repeat count command
The specified command, which is subject to the same restric‐
tions as the command in the one line if statement above, is
executed count times. [..]并且来自if文档:
if (expr) command
[..]
command must be a simple command, not an alias, a pipeline, a
command list or a parenthesized command list, but it may have
arguments. [..]看来这不是你能做的事。
要解决这个问题,您可以使用一个简单的包装脚本。
发布于 2017-04-25 15:15:30
我认为你可以用"eval“来表示,例如:
repeat 7 eval "cmd1;cmd2"发布于 2016-04-13 21:09:52
另一个解决办法是使用ZSH。
% repeat 3 (echo hi; echo there)
hi
there
hi
there
hi
there
% https://unix.stackexchange.com/questions/276300
复制相似问题