Re: find and replace text
- From: Rick Mattern <rmattern@xxxxxxxxx>
- Date: Sat, 13 Aug 2011 20:47:20 -0700 (PDT)
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.
.
- Follow-Ups:
- Re: find and replace text
- From: Bill Marcum
- Re: find and replace text
- References:
- find and replace text
- From: Rick Mattern
- Re: find and replace text
- From: Ben Bacarisse
- Re: find and replace text
- From: Ivan Shmakov
- find and replace text
- Prev by Date: Re: URL http://infoterms.com is a free resource of Categorized Glossary, Dictionary and Definition of Terms
- Next by Date: Re: find and replace text
- Previous by thread: Re: find and replace text
- Next by thread: Re: find and replace text
- Index(es):
Relevant Pages
|