Created
March 29, 2011 22:45
-
-
Save rafaelrinaldi/893516 to your computer and use it in GitHub Desktop.
Repeats a character how many times you want.
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
# | |
# Repeats a character how many times you want. | |
# | |
# $1 The character you want. | |
# $2 How many times you want. | |
# | |
repeat() { | |
character=$1 | |
times=$2 | |
string=$(printf "%""$times""s") | |
echo "${string// /$character}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another version: https://gist.github.com/1101070