Page 1 of 1
linux repeat command x times
Posted: Fri Feb 12, 2021 6:01 pm
by mister_v
Hey,
is there a way to repeat a command several times ?
with out re-typing the command.
Re: linux repeat command x times
Posted: Fri Feb 12, 2021 7:10 pm
by chris
With the up arrow you get the last commands you typed, and press enter to execute it.
If you want to run the same command several times,
you can use for-loop ( in bash)
Code: Select all
for n in {1..3}; do <COMMAND>; done
repeats 3 times
Another option is
watch
If you want to repeat a command every x seconds, ideal for monitoring:
repeats every 10 seconds.
quit with CTRL+C