Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 May 2015 16:20:07 -0400
From:      Alex Merritt <>
To:        Nancy Belle <>
Cc:        freebsd-questions <>
Subject:   Re: Find and replace content in 100 lines
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
Hello Nancy,

On Thu, Apr 30, 2015 at 8:58 PM, Nancy Belle <> wrote:
> Here's the need to fix about 100 lines in a single *.html file:
> find this "../../../arch1/arch14"
> replace with "../../../../../../foo/foo2/foo3/arch1/arch14"
> The quotes are there too.

You want sed with the search/replace feature, generally:

sed s/regular expression/replacement/flags

like so

sed -i .orig

Those single quotes are important, to prevent the shell from doing any
interpretation within anything enclosed between them (e.g. environment
variables, if there were any, and from removing the double quotes). The
single quotes aren't important to sed.

The colon (a forward slash in the example) is the delimiter character, and
can be any character you like (except backslash and newline). Pick one
which does not appear in your strings you are searching and replacing.

-i tells sed to edit the file directly, first making a copy with the given
extension as the backup.

Hope this helps,

Want to link to this message? Use this URL: <>