Created
May 18, 2018 15:47
-
-
Save oscarkramer/fb22183f84386f3737a255ac62a5f01e to your computer and use it in GitHub Desktop.
Bash script to output a horizontal line spanning the width of the terminal using dashes (or optional string provided)
This file contains hidden or 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: printHorizontalLine [c] | |
function printHorizontalLine { | |
local c="-" | |
local strlen=1 | |
if [ -n "$1" ]; then | |
c=$1 | |
strlen=${#c} | |
fi | |
echo | |
x=0 | |
N=$(tput cols) | |
while [ $x -lt "$N" ] | |
do | |
echo -n $c | |
let x=$x+$strlen | |
done | |
echo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment