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

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 1 May 2015 18:18:12 -0400
Alex Merritt <merritt.alex@gmail.com> wrote:

> 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

Yes, much neater, except that you will need sed -E otherwise you'd need
to escape all the grouping parentheses.

And to make it even more compact, how about

curlew:/tmp% cat input.html

aa"../../../arch1/arch14"bb
ccc"../../d1/arch1/arch14"ddd
ee"../../../arch1/arch14"ff

curlew:/tmp% sed -E 's:(([.]{2}/){3}):\1\1foo/foo2/foo3/:' input.html

aa"../../../../../../foo/foo2/foo3/arch1/arch14"bb
ccc"../../d1/arch1/arch14"ddd
ee"../../../../../../foo/foo2/foo3/arch1/arch14"ff

-- 
Mike Clarke



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150502102025.2e970d51>