On Wed, Feb 21, 2001 at 11:46:30AM -0600, mjn wrote:
> I am looking to walk a directory structure, look at all the files ending
> in .html, and examine them for a bit of text and replace that text if its
> found.
>
> Awhile ago someone was kind enough to answer me for doing something like
> this if all of the files are in a certain directory but I haven't found a
> way to do this recursively.
>
> I tried this:
>
> perl -pi.bak -e 's/bob/dick/' testing/.
Try:
find testing/ -name "*.html" -print -exec perl -pi.bak -e 's/bob/dick/' {} \;
find directory -name "*.html" - finds all files below the given directory
with the suffix .html
-print - print the name of the files found to standard out
-exec - runs the specified command, where {} is replaced by the filenames
that find found.
\; - is piece of syntax whose reason for existing I never understood.
HTH,
Jim
--
Jim Crumley |
crumley at fields.space.umn.edu |
Work: 612 624-6804 or -0378 |