Skip to content

Instantly share code, notes, and snippets.

@cameroncros
Created May 7, 2019 13:15
Show Gist options
  • Save cameroncros/a4dfb97c6dc9591ea98dc9e6b7201f4a to your computer and use it in GitHub Desktop.
Save cameroncros/a4dfb97c6dc9591ea98dc9e6b7201f4a to your computer and use it in GitHub Desktop.
#!/bin/bash
right_adjust () {
WIDTH=$(tput cols)
CHARS=$(echo $1 | wc -c)
PADDING=$(($WIDTH-$CHARS))
SPACES=""
val=$(printf "%*s%s\n" $PADDING " " "$1")
echo "$val"
}
right_adjust "Strings"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment