From: Fergal Daly (fergal at domain esatclear.ie)
Date: Sat 03 Apr 1999 - 16:01:41 IST
At 18:03 02/04/99 +0100, you wrote:
>Hi,
>does anybody know where I can find a site with perl scripts that can be
>used for let say - modifying every occurrence of a particular regxp in a
>group of directories and other related activities ?
>
> ...shane D
It can be done from the command line - under a unix system
perl -pi.bak -e 's/searchpattern/replacestring/g' *.txt
will replace all occurrences of 'searchpattern' with 'replacestring' in the
all the *.txt files in the current directory
use
perl -pi.bak -e 's/searchpattern/replacestring/g' `find -name '*.txt'`
to do it to all *.txt files in all subdirectories too (note the find
command is in back quotes). These will also make backups of the changed
files (remove the .bak to stop this). See the perlrun manpage for exactly
what the options do,
Fergal
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:06 GMT