Welcome to LQ!
To get better exposure your post has been moved to the Programming forum where it is more appropriate.
As already suggested, please place your code snippets inside [CODE]...[/CODE]
tags for better readability. You may type those yourself or click the "
#" button in the edit controls.
Finally, also as suggested by rtmistler, your loop code is nearly sufficient, but in the output line you should use
echo or
printf instead of
cat, along with some formatting to get the desired result. With
echo you will need to insert the
# separators shown in your example, or with printf put them in the format string.