sed/awk script to format a file?? 
Author Message
 sed/awk script to format a file??

Using gawk:

set the record separator to be , and the field separator to be :

Then for each record with no /^"sortname:/
gsub all the "s to nothing, and printf two
strings, $1 concatted with the : right-padded and $2.

You're only in problemsville if you want to preserve any :s or "s.



>Can someone give me an example of a script in sed/awk that would format
>this type of text file:

>"sortname: Anderman","Name: Tere J. Anderman","Title: Senior Secretary,
>Member Relations and Communications","Division: Member Relations and
>Communications","Phone: 312/XXX-XXXX","Fax: 312-XXX-XXXX","Email:

>"sortname: Arca","Name: Anna Arca","Title: Administrative Aide, Contract
>and License Management","Division: Legal and Contract Services","Phone:

>TO this output:

>Name:     Tere J. Anderman
>Title:    Senior Secretary Member Relations.....
>Division: Member Relations......
>Phone:    XXX/XXX-XXXX
>Fax:      XXX-XXX-XXXX

>Any help is greatly appreciated.


WWW: http://www.*-*-*.com/ ~phouston/ | Opinions are mine.
Phone: +44-1865-792542                | Facts are everyone's.
Fax:   +44-1865-58817                 |

Thu, 10 Sep 1998 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Run awk from within sed script?

2. log file processing - awk or sed

3. Using awk And/Or sed To Edit Fourth Field Of File

4. How to get info from a file with sed/awk/perl

5. deleting records in a file using AWK, SED, or kshell

6. Getting awk (or sed or anything else) to put single quotes into file

7. Creating an awk script to extract other scripts from a file

8. Awk script to re-format columns

9. formatting a text file with awk

10. Replacing a string from an input file within awk script

11. I want to put my awk file into ksh script

12. piping input files into awk script


Powered by phpBB® Forum Software