Date: Fri, 1 May 2015 16:20:07 -0400 From: Alex Merritt <merritt.alex@gmail.com> To: Nancy Belle <belle@antennex.com> Cc: freebsd-questions <freebsd-questions@freebsd.org> Subject: Re: Find and replace content in 100 lines Message-ID: <CADK3taLyW0sVoHQZ-pjm=VZUMj5Rnekz9jhvuLVyGV3DzHmYNw@mail.gmail.com> In-Reply-To: <DM__150430194617_07750665831@mail.antennex.com> References: <DM__150430194617_07750665831@mail.antennex.com>
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 <belle@antennex.com> 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 's:"../../../arch1/arch14":"../../../../../../foo/foo2/foo3/arch1/arch14":g' input.html 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, Alex
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CADK3taLyW0sVoHQZ-pjm=VZUMj5Rnekz9jhvuLVyGV3DzHmYNw>