Tables and borders

when i do this:

cat HITS

i get the following displayed:

sport.hits:87.114.172.31 Thu Sep 28 22:45:12 GMT 2006

how do i put this information into a bordered table?

so it will output like this:

...........File / IP..................Day.....Month.....Date............Time..............Year
sport.hits:87.114.172.31......Thu......Sep....... 28........22:45:12 GMT...... 2006

Don't know what you really want, but quite likely it would suit your needs to import that file as csv file into some spreadsheet like OpenOffice Calc and use space as separator instead of comma.

basically what i want is for my output to be displayed in a table that has a border.

i am running a script that searches ip adresses from various files.
the files are displayed (using cat HITS) once they have been searched.
they are displayed from a file called HITS

they are displayed in a list like this when they are output:

adventure.hits:223.79.87.212 Tue Sep 05 02:19:02 GMT 2006

i want to be able to have this output placed in a table format with borders and headings for each column:

File / IP
Day
Month
Date
Time
Year

does this explain it a bit better?

If you know html, it's not too hard to wrap the data with row and cell tags, and also insert the remainder of the page layout tags, so the resulting file will open with any browser, and look like a half-way decent table with lines.

A few years ago, I did something similar where I generated html code from a program I wrote in a freeware version of Basic of all things.

it wont be running on the internet. but i do know html.

would it still work?

What do you want to do with that table?

Use as input for some dumb script requiring constant length fields -> you need a real script solution
Simply have good looking logs -> go for csv or html idea

html idea: no, you don't need to be connected to the internet therefore, you just need a browser to view that html file. Even if you are on a text terminal (and do not want to copy that file to some X-machine) you can use lynx or w3m to view that html file.

ok basically this is my script:

I want to output "cat HITS" into a table just to show the user their results from the search. i just wanted to make the display clearer by adding column and row borders and column headings.

Yes. html pages do not have to go thru the internet to be able to be opened like an internet page. As long as whoever gets the file has an internet browser, the browser will be used to open it.

***************** Thread Closed *******************

Just my 2 cents but formatting tables and such around this output would best be done in Perl or Python where it would only add a few lines more. In BASH this could almost double your script size I think since to do it *right* you'll want to write some functions to calculate lengths and draw lines and such. For instance in Perl to print a "line" you can just do

print "-" x 5

and that will output

-----

. In BASH you'd have to do

for ((i=0;i<5;i++)); do echo -n '-'; done

And that's just the tip of the iceberg. Good luck though. I empathize with the BASH addiction.