If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Need help in Sed Command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-21-08, 01:15
raghav1982 raghav1982 is offline
Registered User
 
Join Date: Nov 2007
Posts: 4
Red face Need help in Sed Command

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 !!!
Code ::


sed '
/'$fld1'/ i\
Name' temp.txt > man8.txt

sed '
/'<'/ i\
Email Address' man8.txt > man9.txt

sed '
/'['/ i\
Date of Expire' man9.txt > man10.txt

Please help me on this .. I am in need of a code
Reply With Quote
  #2 (permalink)  
Old 03-25-08, 07:45
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
What should the output look like?
Reply With Quote
  #3 (permalink)  
Old 03-25-08, 08:59
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
It seems you need to prefix the name with the word name
Why don't you just do that from your original script e.g.
echo "name: $name"

If you want fixed length output use printf in your original script e.g.
Code:
cat <<EOF | while read n e d
x y z
aa bbb cc
EOF
do
  printf "%-5s %-10s %-10s\n" $n $e $d
done

x     y          z         
aa    bbb        cc
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On