tip@trylinux:~/blog$ cat lineing-up-fields-with-bash-or-other-programming-languages.md
# Lineing up fields with BASH (or other programming languages)
Author: tip
Date: 2008-04-04 00:00:00
Tags: bash, linux, tips

Learned a couple things about bash today. I was wanting to print something out nicely, so I was using tabs to separate fields. As you know, nothing ever lines up if you do not have values very similar in size. So I was about to search Google for the problem when I had a moment of sheer brilliance. :) I thought I'll just concatenate a bunch of spaces on the end of the variable and then use cut to grab how many characters I want. I was very proud of myself, but then bash quickly humbled me by condensing all my spaces I had added to the variable.

So, back to the all knowing Google. Turns out you have to quote your variable when you use it if you don't want bash to truncate the spaces. So I quoted my variable when using it and all is good.

BUFFER="$VAR                                                                "  
NICE_VAR=`echo "$VAR" | cut -c -15`  
echo "$VAR $VAR2"
EOF