[plug] multi-file find & replace

Bevan Broun bevanb at ee.uwa.edu.au
Fri Oct 23 15:57:31 WST 1998


on Fri, Oct 23, 1998 at 03:56:53PM +0800, Shackleton, Kevin <kshackleton at agric.wa.gov.au> wrote:
> I have a web site (done in frontpage) that refers to everything as
> ".htm".  Apache seems to prefer ".html".  How can I quickly find all
> occurrences in all files of '.htm"' and change them to '.html"'?  Some
> combination of shell and sed I suppose . .

Change to the top of the directory tree that you want to change. If you
are using a bourne shell (/bin/sh for example) do:

for f in `find . -name '*.htm' -print`;do
>g=`echo $f | sed -e 's/$/l/'`
>cp $f $g
>done

But there are many ways to do it.

BB
-- 
Bevan Broun                                           ph (08) 9380 1587
Computer Systems Officer                             fax (08) 9380 1065
Dept. Electrical and Electronic Engineering      
University of Western Australia                                 rm. G70


More information about the plug mailing list