Date: Thu, 24 Sep 2015 12:02:01 -0400 From: "Chad J. Milios" <milios@ccsys.com> To: freebsd-questions@freebsd.org Subject: Re: Find and replace Message-ID: <56041E79.1030505@ccsys.com> In-Reply-To: <2015092410262490833415@antennex.com> References: <2015092410262490833415@antennex.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 9/24/2015 11:26 AM, chino@antennex.com wrote: > Am running FBSD-9.3 and apache-24 > > I need to find and replace several strings with "nothing" (not the word but a blank) and I cannot recall how to handle the syntax for the "new" portion if using sed as below. In other words, I want the *.html file to NOT display the graphic with the same pix.gif file name now there in about 1000 HTML files. > This script: sed -i.bak s/old/new/g fileLike this:#find, etc | sed -i.bak s/pix.gif//g fileThanks in advance for any help! > > > Warmest regards, > Mark Chino > -- > chino@antennex.com > www.antennex.com > you are looking for `xargs`. also consider using the `-print0` operator (thats a zero) with find along with `-0` flag to xargs if your filenames/directories contain any characters special to the shell (like spaces). find /within/this/directory -type f -print0 | xargs -0 sed -i.bak 's/find this/replace with that/g' as a side note, if you do exactly as you described, wont you be left with many broken <img> tags? dont you want to remove the entire <img> tag from your html?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56041E79.1030505>