I wish to have a command that executes a specified command a specified number of times.
For example,
should execute 'echo abc' three times.
Closest I can get is this bash function:
Code:
function multiq { i=$1; while [ $i -gt 0 ]; do $2; i=$(( $i - 1 )); done; }
,which is used like :
Code:
multiq 3 'echo abc'
.
I also want to have a command that opens a specified x application a specified number of times. For example,
Code:
multix 3 xterm python
should open three xterm windows with python as shell, that is same as executing 'xterm python &' three times.
I tried this bash function:
Code:
function multix { i=$1; while [ $i -gt 0 ]; do $2 & ; i=$(( $i - 1 )); done; }
, but this results in bash syntax error.
How should I implement multi and multix? Are there programs that does similar thing?