Last active
April 18, 2016 10:20
-
-
Save rjp/8d70691a268be562f9c92a8baecb1344 to your computer and use it in GitHub Desktop.
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
# Highlight a span from a given block of characters | |
# | |
# usage: ./fillspan spanofcharacters min max | |
# | |
# e.g. ./fillspan 123456789ABCDEF 1 5 => [12345 ] | |
# ./fillspan 123456789ABCDEF 10 15 => [ ABCDEF] | |
# ./fillspan 123456789ABCDEF 5 9 => [ 56789 ] | |
bar=$1 | |
min=$2 | |
max=$3 | |
blank=$(echo "$bar" | tr -c ' ' ' ') | |
premin=$((min-1)) | |
len=$((max-min+1)) | |
postmax=$((max+1)) | |
echo "[${blank:0:$premin}${bar:$premin:$len}${blank:$postmax}]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment