Need Help!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Help!!!
# 8  
Old 03-20-2008
Ok sure ..

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

The above sed will add a line above the Variable .. but when i am trying to add email address ((Searching for this String and add Email above it )) and search for this ([) and add Date above it .. i know that i am sure i am wrong in executing the sed statements .. Please correct me
# 9  
Old 03-21-2008
Let me know if i am right !!
# 10  
Old 03-21-2008
Hi .. I think we can use it using awk command ..

Just add the Header information in it ..

Since my outputs are not static . i am struck in proceeding !!

Thankyou
# 11  
Old 03-21-2008
According to your description above. I write down a script as follow.
Wish to help you!

Assume there is a space between [Date: and 2008-05-16]
Code:
>cat infile
unixytreqasadddd <unix_unix@unix.com> [Date: 2008-05-16]

>cat format.sh
#!/bin/bash

awk '
    BEGIN { printf "%10s  %20s %10s\n", "Name", "Email_Addr", "Date" }
    {

      name = $1;
      addr = substr($2,2, length($2)-2);
      date_time = substr($4, 1, length($4) -1);

      printf "%10s  %20s  %10s\n", name, addr, date_time
      print $0
    }
    ' infile

>./format.sh
      Name            Email_Addr       Date
unixytreqasadddd    unix_unix@unix.com  2008-05-16
unixytreqasadddd <unix_unix@unix.com> [Date: 2008-05-16]

Regards
.Aaron
Login or Register to Ask a Question

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