Forked from saimonmoore/bash function: execute command n times
Created
August 22, 2011 15:07
-
-
Save tokland/1162599 to your computer and use it in GitHub Desktop.
A bash function that executes a command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# $loopc 3 echo 'hello world' | |
# hello world | |
# hello world | |
# hello world | |
# | |
function loopc { | |
LIMIT=$1 | |
shift 1 | |
for((i=0; i<$LIMIT; i++)); do | |
"$@" | |
done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# $loopc 3 echo 'hello world' | |
# hello world | |
# hello world | |
# hello world | |
# | |
function loopc { | |
local LIMIT=$1 | |
shift 1 | |
for((i=0; i<$LIMIT; i++)); do | |
"$@" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment