Find and replace content in 100 lines

Mike Clarke jmc-freebsd2 at milibyte.co.uk
Fri May 1 21:29:51 UTC 2015


On Fri, 1 May 2015 16:20:07 -0400
Alex Merritt <merritt.alex at gmail.com> wrote:

> You want sed with the search/replace feature, generally:
> 
> sed s/regular expression/replacement/flags
> 
> like so
> 
>  
> '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.

-- 
Mike Clarke


More information about the freebsd-questions mailing list