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:
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.
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.
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.
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.