![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Need Help!!!
Hi All
I have written a Shell script which will Produce an Output like this :: unixytreqasassdd <unix_unix@unix.com> [Date: 2008-05-16] I just need to add the Following in the Above which should be of proper lenghts:: Name Email Address Date unixytreqasassdd <unix_unix@unix.com> [Date: 2008-05-16] Since the name , email address and Dates of various lenghts , i have make the report user Friendly .. I have tried adding an Echo command but didnot work properly . So can anyone help me on this !!! Thanks for your Help !! |
| Forum Sponsor | ||
|
|
|
|||
|
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 |
|
|||
|
Quote:
You will also find that people who ask others to do their work for them get nothing, or close to it. Please make an attempt and post it when you get stuck. You'll get a much better response that way. ShawnMilo |
|||
| Google The UNIX and Linux Forums |