Chop and replace method??

jd1008 jd1008 at gmail.com
Sat Apr 4 17:39:21 UTC 2015



On 04/04/2015 11:34 AM, Jon Radel wrote:
> 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 radel.com
>
>
>
Hi Jon,
should not the args include

-s, --separate

               consider files as separate rather than as a single 
continuous long stream.




More information about the freebsd-questions mailing list