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
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!