Chop and replace method??

Jon Radel jon at
Sat Apr 4 17:34:20 UTC 2015

On 4/4/15 12:48 PM, Nancy Belle wrote:
> Hi freebsd-questions
> I have a really big problem to solve and save hours & hours of time to correct hundreds of file links because of moving a very large section within a web site. I have this now:
> 1) <a href="../../../archival/archive13/Jan14/Jan114/intro-frankant.html">
> and need to chop off this portion of above link example:
> 2) ../../../archival/archive13/
> leaving this as the correct link instead:
> 3) <a href="Jan14/Jan114/intro-frankant.html">
> The front portion to chop is always the same while the rest of the link always varies and should be left as is.
As always, it pays to have a really good backup before applying random 
scripts that can trash your files in one easy step, particularly those 
from friendly strangers on the Internet.  :-)

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

should do what you asked for.  But test on copies.  Really!

And use a different extension than .bak if you already have .bak files 
you care about.

--Jon Radel
jon at

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3870 bytes
Desc: S/MIME Cryptographic Signature
URL: <>

More information about the freebsd-questions mailing list