Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Apr 2015 00:21:49 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Jon Radel <jon@radel.com>
Cc:        Nancy Belle <belle@antennex.com>, freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: Chop and replace method??
Message-ID:  <20150405002149.e11077b2.freebsd@edvax.de>
In-Reply-To: <55202099.9090908@radel.com>
References:  <DM__150404113753_01984604235@mail.antennex.com> <55202099.9090908@radel.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Allow me a little improvement for readability:

On Sat, 04 Apr 2015 13:34:17 -0400, Jon Radel wrote:
> sed -i .bak 's/href=\"..\/..\/..\/archival\/archive13\//href=\"/' *.html

You're using \/ to distinguish the '/' characters from the /
in the regex. But you don't have to - just replace the / of
the sed command with something that is _not_ part of the
search & replace expression, for example |, such as:

	% sed -i .bak 's|href="../../../archival/archive13/|href="|' *.html

As you can see, escaping " inside '...' also isn't neccessary.
Depending on the patterns in the input, you could add 'g' for
global search & replace (here: like s|before|after|g).


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



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