home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.shell:3113 comp.unix.questions:9375
- Path: sparky!uunet!usc!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!friedman
- From: friedman@gnu.ai.mit.edu (Noah Friedman)
- Newsgroups: comp.unix.shell,comp.unix.questions
- Subject: Re: What's wrong with this sed command?
- Message-ID: <FRIEDMAN.92Jul24041305@nutrimat.gnu.ai.mit.edu>
- Date: 24 Jul 92 08:13:05 GMT
- References: <MONTNARO.92Jul21160321@ausable.crd.ge.com>
- Sender: news@ai.mit.edu
- Followup-To: comp.unix.shell
- Distribution: comp
- Organization: Free Software Foundation, 675 Mass Ave. Cambridge, MA 02139
- Lines: 27
- In-reply-to: montnaro@ausable.crd.ge.com's message of 21 Jul 92 21:03:21 GMT
-
- In article <MONTNARO.92Jul21160321@ausable.crd.ge.com> montnaro@ausable.crd.ge.com (Skip Montanaro) writes:
- >I'm trying to use sed to trim off all leading "./" patterns from source
- >filenames in make rules. On an IBM RS6000 the following works as I expected:
- >
- > echo 'enquire.o: ./././enquire.c' | sed 's?: \(\./\)\{1,\}?: ?'
- >
- >yielding
- >
- > enquire.o: enquire.c
-
- It looks like you're trying to use some sort of extended regular
- expression here to match a consecutive range of regexps (in this case,
- starting with the first and going to the end). I've never seen a version
- of sed that implements this (including GNU sed). The following does what
- you wanted, however, and is quite portable:
-
- echo 'enquire.o: ./././enquire.c' | sed 's?: \(\./\)\1*?: ?'
-
- The reason why this works should be obvious.
-
- >Have I incorrectly specified the sed command or are one (or more) of the
- >vendors' sed implementations incorrect? If so, which one(s)? I'm inclined to
- >believe the IBM is correct and the others are bugged.
-
- I don't know. IBM may have made such an extension, but I'm not familiar
- with it. But a trivial modification to your example makes it work across
- all the platforms you mentioned (I didn't bother quoting them in my reply).
-