Find and replace
Chad J. Milios
milios at ccsys.com
Thu Sep 24 16:02:07 UTC 2015
On 9/24/2015 11:26 AM, chino at 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 at 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
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?
More information about the freebsd-questions