Re: find and replace text

On Aug 12, 7:34 pm, Ivan Shmakov <i...@xxxxxxxxxxxxxxxx> wrote:
Ben Bacarisse <ben.use...@xxxxxxxxx> writes:
Rick Mattern <rmatt...@xxxxxxxxx> writes:

 >> I need to search for files named turboOptions.state and replace text
 >> "Auto" with "Disable" The find with -exec looks like a good fit but
 >> does it have to be a file that contains the command or is there a
 >> way to pass the command ?

 >> find . -name turboOptions.state -exec sed 's/Auto/Disable/g' {} \;

 > Did you try?

 > The main problem you'll have is the "replacing text" usually means
 > permanently -- in place -- in the file.  If your sed has a -i
 > option you are good to go,

        And if indeed has, I'd recommend to use the -exec + form instead
        of the -exec \; one, like:

   -exec sed -i -e s/Auto/Disable/g -- {} +

        That way, sed(1) would be called for a bunch of files at a time,
        not for a single one, thus saving some CPU cycles.

 > but if not, the use of temporary files and so on means that I would
 > write a small script to do the replace and put that after the -exec.

FSF associate member #7257

I havent had a chance to try it out. I thought that I read that the -
exec would execute a file and
not a command.