[geeks] Quick sed question

Greg A. Woods woods at weird.com
Sun Jun 23 15:04:43 CDT 2002


[ On Saturday, June 22, 2002 at 11:49:23 (-0400), alex j avriette wrote: ]
> Subject: Re: [geeks] Quick sed question
>
> >> 	sed -e 's/^[ 	]*//'
> >
> > Or more efficiently :
> >
> > sed -e 's/^[     ]+//'
> 
> well sure its a little more efficient, but its not the same expression.

Well the requirements Josh stated would have been equally well met with
this expression:

 	sed -e 's/^[ 	][ 	]*//'

so the '+' form is equally correct for his needs.

(and if you think about the actual substitution that's happening its
obvious they both reduce to the very same result -- it's just that a
naive implementation of 'sed' can't give the necessary hints to the
regex compiler to make the match work exactly the same in both cases,
and thus the '+' form ends up being a lot faster to run)

-- 
								Greg A. Woods

+1 416 218-0098;  <gwoods at acm.org>;  <g.a.woods at ieee.org>;  <woods at robohack.ca>
Planix, Inc. <woods at planix.com>; VE3TCP; Secrets of the Weird <woods at weird.com>



More information about the geeks mailing list