在循环中运行可执行文件

时间:2011-11-30 19:52:21

标签: unix executable

我有一个测试(基本上是一个可执行文件),我想多次运行。是否有某种类型的脚本或其他什么要做?基本上我想运行

terminal>./test   and do this like n times.

这是针对命令行的。

p.s我没有说出可执行测试的名称..我只是用了一个mneumonic来帮助我说的话

2 个答案:

答案 0 :(得分:2)

请勿致电test您的计划。

您可以使用重复内置zsh,例如

 repeat 12 ./test

答案 1 :(得分:1)

怎么样

for i in `seq 1 $n`; do ./test ; done

这适用于所有类似sh的shell。作为旁注,命名可执行的“测试”不是最好的主意:

# there's a shell builtin
[cnicutar@fresh ~]$ type test
test is a shell builtin

# and a separate executable, for good measure
[cnicutar@fresh ~]$ which test
/usr/bin/test