On Tue, 2003-09-09 at 15:25, Jacob Fugal wrote:
> On Tue, 2003-09-09 at 15:16, Michael Ryan Byrd wrote:
> > On my redhat box, I need to search through a bunch of directories (nested) in my
> > webroot that contain many different kinds of files.
> >
> > Inside all the .txt and .html files I need to replace the word "foo" with "bar"
> >
> > Anybody got a nifty command line creation for that task?
>
> find . -name *.txt -or -name *.html | xargs replace foo bar --
After reading Gary's post, I have a few modifications to my find
statement:
find . -type f "(" -name "*.txt" -or -name "*.html" ")" | ...
where the xargs portion is the same as before.
I discovered that:
* "-type f" is important, because replace will actually replace a
symbolic link it finds with a real file
* Quotation marks around the file patterns is important, because find
would start acting erratically if there were symlinks in any
subdirectories, and barf outright if there's a symlink in the directory
I start it from. Weird.
* Quotation marks around the parentheses were required in bash, though
it may not be the case for all shells. YMMV.
Jacob
____________________
BYU Unix Users Group
http://uug.byu.edu/
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list