bash: for – looping to repeat commands

A one liner to repeat a task/process N number of times.

Perform 5 times:

1
for n in {1..5}; do <command>; done</command>

Add a function to .bashrc / .bash_profile:

1
2
3
4
5
6
7
function run() {
number=$1
shift
for n in $(seq $number); do
$@
done
}

Usage:

1
run 5 <command></command>

SOURCE: ShellHacks