home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / shell / 3103 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  1.6 KB

  1. Xref: sparky comp.unix.shell:3103 comp.unix.questions:9343
  2. Newsgroups: comp.unix.shell,comp.unix.questions
  3. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!ugle.unit.no!news
  4. From: Harald.Eikrem@delab.sintef.no
  5. Subject: Re: What's wrong with this sed command?
  6. In-Reply-To: john@physiol.su.OZ.AU (John Mackin)
  7. Message-ID: <1992Jul23.192253*Harald.Eikrem@delab.sintef.no>
  8. Keywords: sed' too much
  9. Sender: news@ugle.unit.no (NetNews Administrator)
  10. Organization: SINTEF DELAB, Trondheim, Norway.
  11. References: <MONTNARO.92Jul21160321@ausable.crd.ge.com> <glaze.2520@glaze>
  12.     <1992Jul23.090023.17661@physiol.su.OZ.AU>
  13. Date: 23 Jul 92 19:22:52
  14. Lines: 28
  15.  
  16. John Mackin on `sed':
  17. ! What the original poster wants cannot be done in one step with the ed
  18. ! subset of regular expressions (as used by sed).  If sed accepted full regular
  19. ! expressions, a la egrep, then the command would be:
  20. !
  21. !     sed 's?: (\./)*?: ?'        WRONG WRONG WRONG
  22.  
  23. You can do that with GNU sed.  One more reason for everybody to rm /bin/sed
  24. and install the GNU derived one..... :)  The *only* drawback is that it
  25. probably runs a bit slower.
  26.  
  27. ! but since sed doesn't do full RE's, that won't work.  You need
  28. ! another approach.  Since you can't do it in one step, do it
  29. ! in several:
  30. !
  31. !     sed -e ': loop' -e 's?: ./?: ?' -e 't loop'
  32.  
  33. I've always wondered why ":label; ....." was doomed to be unusable.
  34. The way it is, I believe I may put it as
  35.  
  36.         echo 'rubbish.o: ././././././rubbish.c' | /bin/sed ':;
  37.           s;: \./;: ;; t;'
  38.  
  39. for what it's worth :).  (Hey, that's a non-csh continuation there, you do
  40. remember to make that   ....sed ':;\   before entering the 1.st newline in
  41. csh/tcsh, dont you?).
  42.  
  43.    ~~harald E.
  44.