#!/bin/sh
# Create a readable table
#
# First replace all the new lines (\012) by spaces. We need the echo
# to assure that a new line is appended to the result. 
#
(tr '\012' ' ';echo) |\
#
# Now we hanve the table on one long line. We want to insert new lines
# at specific points namely just before every item name. We will make
# use of the fact that no } are present in the text and that no item 
# names start with a number. Put a } at the places where we want a 
# new line: before item names  
#
sed 's/ \([^0-9 ]\)/ }\1/g' |\
#
# Now we replace the } character by new lines:
#
tr '}' '\012' |\
#
# We want nice columns, don't we? We will add some spaces to all sole 
# characters and character pairs. Never mind this part of the program,
# it will work if the table elements are smaller than 1000.
#
sed 's/\([0-9] \)/\1  /g' |\
sed 's/\( [0-9] \)/  \1/g' |\
sed 's/\( [0-9][0-9] \)/ \1/g' |\
sed 's/\([0-9] \)  /\1/g'
#
# Use this part of code if some table elements are larger than 999 but
# smaller than 10000. You will most certainly have to change the size
# of your window and your font size to be able to view the output of
# this on seperate lines. Remove the #'s before the sed commands and
# insert #'s before the four sed commands above.
#
#sed 's/\([0-9] \)/\1  /g' |\
#sed 's/\( [0-9] \)/   \1/g' |\
#sed 's/\( [0-9][0-9] \)/  \1/g' |\
#sed 's/\( [0-9][0-9][0-9] \)/ \1/g' |\
#sed 's/\([0-9] \)  /\1/g'
#