delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/01/16:27:42

Date: Sun, 1 Aug 1999 11:39:59 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Dave Scott <dave AT roborat DOT demon DOT co DOT uk>
cc: djgpp AT delorie DOT com
Subject: Re: Global file edit?
In-Reply-To: <19990723.1942.13701snz@roborat.demon.co.uk>
Message-ID: <Pine.SUN.3.91.990801113928.20304Q-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019