[olug] Text search and Replace

Terry td3201 at yahoo.com
Tue Nov 25 16:52:23 UTC 2003


lots of ways to do it, here is a 1-liner for you:
perl -i.backup -pe 's/foo/bar/' filename

you can write a loop around this easy enough in bash
to go through all files in a directory.

This replaces all occurrences of foo with bar.  You
might need to tack on a g at the end of the regexp but
I don't think so.

--- Jeff Norton <jnorton at jggt.com> wrote:
> I want to search a directory on my computer and
> replace certain text
> within documents with a new text.
> 
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug


=====
Terry

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree


More information about the OLUG mailing list