Skip to content

Instantly share code, notes, and snippets.

@spasarok
Created October 11, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spasarok/c86c4a814fd8e68f686a0536114b4a55 to your computer and use it in GitHub Desktop.
Save spasarok/c86c4a814fd8e68f686a0536114b4a55 to your computer and use it in GitHub Desktop.
Execute a function with parameters multiple times in bash
# Add to ~/.bash_profile
function loop {
for i in $(seq $2); do $1; done
}
# source ~/.bash_profile
source ~/.bash_profile
# repeat a command with parameters
# loop <command> <count>
$ loop "echo hello world" 3
hello world
hello world
hello world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment