All pastes #396125 Raw Edit

Miscellany

public shellscript v1 · immutable
·published 2007-03-15 14:58 UTC
rendered paste body
#: cat pad.sh#pad a string with a certain amount of chars#arg1 is the string, mandatory#arg2 is the padding length (optional, defaults to 80)#arg3 is the char used for padding (optional, defaults to space)function pad() {        str=$1; len=${2:-80}; char=${3:-\ }; padlen=$(($len-${#str}))        for((i=0; i<$padlen; i++)); do                        str=${str}${char};        done        echo "${str}"}#: #tesing#: pad hello 5 \#hello#: pad hello 10 \#hello######: pad hello 20 -hello---------------#: #seems to work :)