LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] perl resources

[ILUG] perl resources

Fergal Daly fergal at esatclear.ie
Sat Apr 3 16:01:41 IST 1999


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






More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell