This is a quick, but very helpful little script I found out on the net for padding variables.
#!/bin/bash
function lpad
{
word="$1"
while [ ${#word} -lt $2 ]; do
word="$3$word";
done;
echo "$word";
}
function rpad {
word="$1"
while [ ${#word} -lt $2 ]; do
word="$word$3";
done;
echo "$word";
}
lpad 3 5 0
rpad fooby 20 ^
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment