This is easy in perl. For example,

perl -i.bak -e 's/this/that/g' *.files

Does in-place replacements, saving the original versions with .bak extension.

Patrick McCabe

At 01:53 PM 10/23/2003 -0500, you wrote:
>Hey gang,
>
>This may have been covered before, but I was wondering how I can find and 
>replace in files.  I've seen a couple of ways to do this, but the ones 
>I've tried are botched up in some way.  Here's an example of what I'd like 
>to do:
>
>/dir contains about 150 files in it.
>egrep "/^[ \t]some (fancy[.]+regex).*$/" *.files  - shows 20 files with 
>matching lines.
>I'd like to "s/^[ \t]some .+(fancy.+regex).*$/\1/" on those files.
>
>a script like this is doable:
>for file in dir
>    ex "+:g/find/s//replace/" "+:wq" file
>
>but I can't help but think there's a better way, and one with more 
>features like being able to recurse through directories, or is faster, 
>etc.  Is there a egrep/grep/etc tool that can do this?  Or what tool would 
>you recommend?
>
>Thanks in advance...
>Chris Frederick
>
>
>
>_______________________________________________
>TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
>http://www.mn-linux.org tclug-list at mn-linux.org
>https://mailman.real-time.com/mailman/listinfo/tclug-list


_______________________________________________
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
http://www.mn-linux.org tclug-list at mn-linux.org
https://mailman.real-time.com/mailman/listinfo/tclug-list