Article View: comp.unix.shell
Article #131Re: What's wrong with this sed command?
From: Noah Friedman
Date: Fri, 24 Jul 1992 08:13
Date: Fri, 24 Jul 1992 08:13
27 lines
1888 bytes
1888 bytes
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).
Technical Details
Message-ID:
<FRIEDMAN.92Jul24041305@nutrimat.gnu.ai.mit.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!friedmanReferences:
<MONTNARO.92Jul21160321@ausable.crd.ge.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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