在循环中运行可执行文件

发布于 2024-12-19 08:53:16 字数 192 浏览 2 评论 0原文

我有一个测试(基本上是一个可执行文件),我想运行几次。是否有某种脚本或其他东西可以执行此操作?基本上我想运行

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

这是针对命令行的。

ps 我没有命名可执行测试..我只是使用助记符来帮助我所说的

I have a test (which is basically an executable) which I want to run several times .Is there like some sort of script or something to do this?Basically I want to run

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

This is for the command line.

p.s I did not name the executable test ..I just used a mneumonic to help what I was saying

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2024-12-26 08:53:16

不要调用您的程序test

您可以使用 zsh 内置的repeat,例如

 repeat 12 ./test

Don't call test your program.

You can use repeat builtin of zsh, e.g.

 repeat 12 ./test
瘫痪情歌 2024-12-26 08:53:16

怎么样

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

这应该适用于所有类似 sh 的 shell。附带说明一下,将可执行文件命名为“test”并不是最好的主意:

# 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

How about

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

This should work on all sh-like shells. As a side note, naming an executable "test" is not the best idea:

# 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文