Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 May 2015 18:18:12 -0400
From:      Alex Merritt <merritt.alex@gmail.com>
To:        Mike Clarke <jmc-freebsd2@milibyte.co.uk>
Cc:        Nancy Belle <belle@antennex.com>, freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: Find and replace content in 100 lines
Message-ID:  <CADK3taJ98y3M9cSEasMHmr1benaMPm-PpMy-Am=9ZoG=LA6eiQ@mail.gmail.com>
In-Reply-To: <20150501222634.371373f0@curlew.lan>
References:  <DM__150430194617_07750665831@mail.antennex.com> <CADK3taLyW0sVoHQZ-pjm=VZUMj5Rnekz9jhvuLVyGV3DzHmYNw@mail.gmail.com> <20150501222634.371373f0@curlew.lan>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, May 1, 2015 at 5:26 PM, Mike Clarke <jmc-freebsd2@milibyte.co.uk>
wrote:

> On Fri, 1 May 2015 16:20:07 -0400
> Alex Merritt <merritt.alex@gmail.com> wrote:
> >
> 's:"../../../arch1/arch14":"../../../../../../foo/foo2/foo3/arch1/arch14":g'
> > input.html
>
> Although that would almost certainly work OK in the OP's case  it would
> be safer to use:
>
>
> 's:"\.\./\.\./\.\./arch1/arch14":"../../../../../../foo/foo2/foo3/arch1/arch14":g'
>
>  otherwise if there was  something like "../../d1/arch1/arch14" it would
>  become "../../../../../../foo/foo2/foo3/arch1/arch14" which is probably
>  not what would be intended.
>

Hm, yes, the picket fence. How about

sed -i .orig -r
's:"((\.\./){3})arch1/arch14":"\1\1foo/foo2/foo3/arch1/arch14":g' input.html

Group it and repeat as \1

-Alex



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CADK3taJ98y3M9cSEasMHmr1benaMPm-PpMy-Am=9ZoG=LA6eiQ>