Sponsored Content
Full Discussion: Need Help!!!
Top Forums Shell Programming and Scripting Need Help!!! Post 302177228 by ShawnMilo on Thursday 20th of March 2008 11:02:47 AM
Old 03-20-2008
You're basically asking for a way to reformat your entire file into a fixed-width file.

Assuming you're using fixed-width fonts, you can probably get away with this looking correct on the command line. The main problem I see is that the date section has a space in it. If that could be eliminated, you could do this:

1. Define the headers in an array.

2. Split the line on whitespace.

3. Loop through, padding each header element to be as long as the data element for the matching array index.

Of course, if you have multiple lines of data with differing lengths, you'll have to loop through the entire file to find the longest samples, and pad not only the headers but each line of output to line up.

All in all, it's not a very reliable thing to attempt. Unless the data is pretty much never going to change. If your data is never going to change (number of fields and field length), just add an echo line to your script before the other output with the appropriate number of spaces between header fields.

ShawnMilo
 
All times are GMT -4. The time now is 02:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy