[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sed question



On Vi, 06 dec 19, 16:15:51, songbird wrote:
> The Wanderer wrote:
> >
> > For example, 's/hello/newstring/' would be a valid sed 's'-expression,
> > but 's/a/b/newstring/' would not; the former contains three instances of
> > the delimiting token, which is valid, but the former contains four,
> > which is not.
> >
> > If you have the sed expression 's/${oldstring}/newstring/', and you
> > define oldstring as having the value 'hello' then sed sees the first
> > expression, and you get the good result.
> >
> > But if you instead define oldstring as having the value 'a/b', then sed
> > sees the second expression, and you get a syntax error.
> >
> >
> > (Assuming I'm not mixing things up right now, anyway.)
> 
>   :)  thank you for your reply.  now i see it.

One trick to avoid this problems is to use a different delimiter, e.g. '|'.

According to the manual[1][2] any other character is accepted.

[1] https://www.gnu.org/software/sed/manual/sed.html#The-_0022s_0022-Command
[2] as with many (most? all?) GNU programs the full documentation is 
available only as a Texinfo manual, not a man page.

Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser

Attachment: signature.asc
Description: PGP signature


Reply to: