I did not find a "standard" Linux tool to do this job, but I usually preserve my dot files (.bashrc, .vimrc etc.) from installation to installation, so the following is pretty "standard" if you look at it from the perspective of preserving your dot files in new installations:
At the end of your .bashrc or .bash_aliases, put the following definition:
repeat() {
n=$1 #gets the number of times the succeeding command needs to be executed
shift #now $@ has the command that needs to be executed
while [ $(( n -= 1 )) -ge 0 ] #loop n times;
do
"$@" #execute the command; you can also add error handling here or parallelize the commands
done
}
Save the file and either reopen the shell or execute source /path/to/.bashrc
or source /path/to/.bash_aliases
, whichever you choose to modify, in an existing shell.
That's it! You should be able to use it in the following manner:
repeat 100 echo hello
repeat 84 ~/scripts/potato.sh
etc.