Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Multi-line ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 8 Topic 2147 of 2236
Post > Topic >>

Re: Multi-line record headers

by William James <w_a_x_man@[EMAIL PROTECTED] > Jan 31, 2008 at 07:46 AM

On Jan 31, 7:28 am, Ed Morton <mor...@[EMAIL PROTECTED]
> wrote:
> On 1/30/2008 4:48 PM, kevin.byf...@[EMAIL PROTECTED]
 wrote:
>
>
>
> > This one has me stumped.  In the below example I'm trying to get the
> > (customer) number (which might also contain capital letters) above
> > each group of contacts to show on every line in front of each
> > contact.  There are no tabs in the file, just spaces.  Some customer
> > numbers have zero contacts, some have many.
>
> > Here's the source:
>
> > 00270
> >  OE DENNIS ANSZ                   OWNER/EXECUTIVE      600/200-0110
>
> > 00275
> >  OE JAMES ARNILD                                       310/755-2079
> >  ZA SHARI                         ACCOUNTS PAYABLE     310/755-2079
>
> > 00300
>
> > 00310
> >  FX                               FAX NUMBER               912-1948
> >  GM JOE                           GENERAL/DIV MGR      376/942-9735
>
> > P00315
> >  FX FAX                           FAX NUMBER           376/788-3443
> >  OE KAREN ZATHO                  PRESIDENT            317/788-3000
> >  ZP KAREN ZATHO                  HOME PHONE           317/788-4014
>
> > And the goal:
>
> > 00270 OE DENNIS ANSZ                   OWNER/EXECUTIVE
> > 600/200-0110
>
> > 00275 OE JAMES ARNILD
> > 310/755-2079
> > 00275 ZA SHARI                         ACCOUNTS PAYABLE
> > 310/755-2079
>
> > 00300
>
> > 00310 FX                               FAX NUMBER
> > 912-1948
> > 00310 GM JOE                           GENERAL/DIV MGR
> > 376/942-9735
>
> > P00315 FX FAX                           FAX NUMBER
> > 376/788-3443
> > P00315 OE KAREN ZATHO                  PRESIDENT
> > 317/788-3000
> > P00315 ZP KAREN ZATHO                  HOME PHONE
> > 317/788-4014
>
> > Any suggestions?
>
>  awk '/^ /{print k $0;next}{k=$1}' file
>
>         Ed.

This discards customer-numbers that have no contacts.

Furthermore, it does not print each telephone-number on a line
by itself.

In addition, it fails to put a blank line between each
group of contacts.




 8 Posts in Topic:
Multi-line record headers
kevin.byford@[EMAIL PROTE  2008-01-30 14:48:13 
Re: Multi-line record headers
kevin.byford@[EMAIL PROTE  2008-01-30 14:52:55 
Re: Multi-line record headers
ptjm@[EMAIL PROTECTED] (  2008-01-31 01:56:49 
Re: Multi-line record headers
kevin.byford@[EMAIL PROTE  2008-01-30 18:23:36 
Re: Multi-line record headers
William James <w_a_x_m  2008-01-31 00:29:52 
Re: Multi-line record headers
Ed Morton <morton@[EMA  2008-01-31 07:28:15 
Re: Multi-line record headers
William James <w_a_x_m  2008-01-31 07:46:56 
Re: Multi-line record headers
Ed Morton <morton@[EMA  2008-01-31 10:06:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 0:22:21 CDT 2008.