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.


Relevant Pages

  • Re: Sleep freezing
    ... >> man exec. ... > form of a standard shell pipeline where each arg becomes one ... > word of a command, and each distinct command becomes a sub- ... The word "execute" means to replace the program running in the calling ...
  • Re: du command failing
    ... directory if the directory does not have a Read or Execute permission. ... From UNIX command line i have executed 'du' command. ... From [exec] manpage: ...
  • RE: COMMAND field of TSO LOGON panel
    ... The issue is that the logon proc being executed directly launches into ISPF, ... If you exit ISPF, allow the exec to run, then reenter ISPF ... COMMAND field of TSO LOGON panel ... However,it didn't execute it. ...
  • Re: exec() gives output??
    ... > I'd like to execute a command on the server ... > particular command takes a long time to execute, ... A successful call to exec() replaces the Perl script with whatever execis ...
  • Re: wScript.Shell Problems
    ... the completion of the underlying process. ... However, the Exec procedure is ... Here is why i went to the RUN command, it is my understanding that the ... EXEC command does not allow for the BOOLEAN indicating wether the ...