有没有更好的方式来在bash运行命令N次? [英] Is there a better way to run a command N times in bash?
本文介绍了有没有更好的方式来在bash运行命令N次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我偶尔会像这样运行bash命令行:
N = 0;而[[$ N -lt 10];做some_command; N = $(第(n + 1)); DONE
要运行 some_command
在连续多次 - 10次这种情况下
通常 some_command
真的是一个命令或管道的链条。
有没有一种更简洁的方式来做到这一点?
解决方案
在运行{} 1..10
做
命令
DONE
I occasionally run a bash command line like this:
n=0; while [[ $n -lt 10 ]]; do some_command; n=$((n+1)); done
To run some_command
a number of times in a row -- 10 times in this case.
Often some_command
is really a chain of commands or a pipeline.
Is there a more concise way to do this?
解决方案
for run in {1..10}
do
command
done
这篇关于有没有更好的方式来在bash运行命令N次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文