Skip to content

Instantly share code, notes, and snippets.

@linknum23
Last active July 13, 2020 16:35
Show Gist options
  • Save linknum23/88aedaa238960d0805a4b10f2fef96bf to your computer and use it in GitHub Desktop.
Save linknum23/88aedaa238960d0805a4b10f2fef96bf to your computer and use it in GitHub Desktop.
bash helper, run a command x number of times
#!/bin/bash
# run bash command x number of times
# ie. 'runx 10 echo "Hello"' will print Hello 10 times
# partially from: https://stackoverflow.com/questions/3737740/is-there-a-better-way-to-run-a-command-n-times-in-bash
function runx() {
for _ in $(seq "$1"); do
eval ${*:2}
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment