Need Help!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Help!!!
# 1  
Old 03-20-2008
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 !!
# 2  
Old 03-20-2008
Any Clue???

Thanks Guys
# 3  
Old 03-20-2008
Hi All

Just to be clear , i need to add Name Email address and Date just above the line .. can anyone help me on this .. i am struck here , not able to proceed !!!

Waiting for replies


THanks
# 4  
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
# 5  
Old 03-20-2008
Can you provie an exaple or the code

I think writing an awk statement above it will solve this
# 6  
Old 03-20-2008
Thanks for your replies !!

Can you please give me an Sample code , so that i can work it out
# 7  
Old 03-20-2008
Quote:
Originally Posted by raghav1982
Thanks for your replies !!

Can you please give me an Sample code , so that i can work it out
Generally, you'll find that everyone will want to help you if you have shown that you have put some effort into solving your own problem. They will fix your code, write code, and make plenty of suggestions.

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
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question