Skip to content

Instantly share code, notes, and snippets.

@oscarkramer
Created May 18, 2018 15:47
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 oscarkramer/fb22183f84386f3737a255ac62a5f01e to your computer and use it in GitHub Desktop.
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)
# 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