Mail Archives: djgpp/1999/08/01/16:27:42
On Fri, 23 Jul 1999, Dave Scott wrote:
> Is there a simple utility available to do something like this :-
>
> edit <existing_string> <replacement_string> <a_bunch_of_filespecs>
Write a batch file that does this for a single file (by redirecting
Sed's output and then mv'ing the result into the original file), then
use `find' to invoke the batch file on every file in turn. Don't
forget to use -dosexec instead of -exec, and don't forget to invoke
the batch file through "command.com /c". Something like this:
find -name '*.c' -o -name '*.cpp' -dosexec command.com /c foo.bat {} ;
Where foo.bat is something like this:
@echo off
sed -e s/[^x]malloc/xmalloc/g %1 > tmp
mv -f tmp %1
Actually, for this to work, you need to give a full pathname of
foo.bat on the `find' command line, or put it somewhere on your PATH,
because otherwise when (and if) it descents into subdirectories, it
will not find foo.bat anymore.
Note that I didn't test all this, so I might be missing something.
- Raw text -