So elaborating a bit on Axel's answer using printf
can do this. If the line width is linewidth then:
a="1.23e-19"
b="hello"
linewidth=30
echo "--------------------------------"
echo "Here come some variables |"
echo " |"
printf "%-${linewidth}s |\n" "a = $a and b = $b"
echo " |"
echo "End of the script |"
echo "--------------------------------"
does exactly what I want. Output:
--------------------------------
Here come some variables |
|
a = 1.23e-19 and b = hello |
|
End of the script |
--------------------------------