[NTLUG:Discuss] Linux script question
Chris Cox
cjcox at acm.org
Mon Jun 16 12:18:17 CDT 2003
Pervaz Allaudin wrote:
> OK I have another linux command question.
>
> I have multiple files in multiple dirs. under a dir. from which I want
> to replace a word and then written back; Either in the same files or
> another dir. as root.
>
> I got till
>
> find src -iname *.ext | xargs sed /oldtext/newtext/
>
> but I cannot get it to write to corresponding files (in the same dire or
> another).
>
> Also another problem I am having is it won't replace the text if I have
> like oldtext.sometext which I need to change to newtext.sometext
>
> I would appreciate some help with this and also would not mind some net
> sources to learn and/or lookup things like this. The two linux books I
> have are basic and inadequate.
I'll steal Kevin Brannen's thunder and share his solution...
Kevin> I found a perl trick the other day that I thought I'd share...
Kevin>
...
Kevin>
Kevin> find <directory> -type f -print | xargs perl -pi -e
Kevin> "s/STRING1/REPLACESTRING/"
Kevin>
Kevin>
Kevin> Kevin
More information about the Discuss
mailing list