I am trying to do some formatting on output data in a script and not positive how to do Left Right justify as well as width. Can anyone point me in the right direction?
You can do it using pure bash:
x="Some test text"
width=" " # 20 blanks
echo "${width:0:${#width}-${#x}}$x"
Output is:
' Some test text' (obviously without the quotes)
So the two things you need to know is ${#var} will get the length of the string in var, and ${var:x:y} extracts a string from x to y positions.
You may need a recent version (tested on GNU bash 3.2.25)
EDIT: Come to think of it, you can do it like this:
echo "${width:${#x}}$x"