The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-19-2008
Registered User
 

Join Date: Sep 2007
Posts: 82
Stumble this Post!
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 !!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Sep 2007
Posts: 82
Stumble this Post!
Any Clue???

Thanks Guys
Reply With Quote
  #3 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Sep 2007
Posts: 82
Stumble this Post!
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
Reply With Quote
  #4 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Jun 2006
Posts: 159
Stumble this Post!
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
Reply With Quote
  #5 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Jan 2008
Posts: 52
Stumble this Post!
Can you provie an exaple or the code

I think writing an awk statement above it will solve this
Reply With Quote
  #6 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Sep 2007
Posts: 82
Stumble this Post!
Thanks for your replies !!

Can you please give me an Sample code , so that i can work it out
Reply With Quote
  #7 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Jun 2006
Posts: 159
Stumble this Post!
Quote:
Originally Posted by raghav1982 View Post
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0