[nycbug-talk] Re: Simple sed question

Okan Demirmen okan
Fri Jan 7 13:46:20 EST 2005


On Fri 2005.01.07 at 13:16 -0500, Francisco Reyes wrote:
> On Fri, 7 Jan 2005, a nice bug wrote:
> 
> >Francisco:
> >>New to sed/awk.. reading a book on them.
> >>Trying to convert:
> >>### Text Text Text
> >>
> >>to
> >>###<tab>Text Text Text
> >
> >
> >echo -e "Text Text Text" |sed -e 's/\(Text Text Text\)/\t\1/g'
> >
> >Just a general example for the tab replacement part (it could have
> >many further permutations depending precisely what you need..)
> 
> 
> Of course it would help if I had explained that "Text Text Text" are 3 
> unknown columns and not literals. :-(
> Real data sample
> 506     AllianceBer Intl PremGr B     AIPBX   8.29    -2.13   -1.54
> 507     AllianceBer Intl PremGr C     AIPCX   8.29    -2.24   -1.54
> 508     AllianceBer Intl PremGrAd     AIPYX   8.87    -1.88   -0.67
> 509     AllianceBer Intl Val A        ABIAX   14.91   5.59    9.79
> 510  AllianceBer Intl Val A    ABIAX   14.91   5.59    9.79
> 511 AllianceBer Intl Val A    ABIAX   14.91   5.59    9.79
> 512 AllianceBer Intl Val A    ABIAX   14.91   5.59    9.79
> 
> 
> Basically what I am trying to do is to have only from the description 
> onward.
> 506 through 509 have a tab
> 510 has 2 spaces
> 511 and 512 have a single space

sed -e 's/^[0-9]*.[ \t]*//g'

okan

> The data is coming from OCR and basically I am cleaning it up in sed so by 
> the time I get it to awk is in good shape. I figured out all the other 
> cleanups this is the only one have not figured out. :-(
> _______________________________________________
> % NYC*BUG talk mailing list
> http://lists.nycbug.org/mailman/listinfo/talk
> %Be sure to check out our Jobs and NYCBUG-announce lists
> %We meet the first Wednesday of the month

-- 
Okan Demirmen <okan at demirmen.com>
PGP-Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xB3670934
PGP-Fingerprint: 226D B4AE 78A9 7F4E CD2B 1B44 C281 AF18 B367 0934




More information about the talk mailing list