Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Apr 2001 19:07:51 -0400
From:      John Capo <jc@irbs.com>
To:        Laurence Berland <laurence@isp.northwestern.edu>
Cc:        questions@freebsd.org
Subject:   Re: OT:Use perl to substitute a string for another in many files
Message-ID:  <20010418190751.A25209@tortugas.irbs.com>
In-Reply-To: <Pine.LNX.4.30.0104181723500.4364-100000@wiggum.isp.nwu.edu>; from laurence@isp.northwestern.edu on Wed, Apr 18, 2001 at 05:25:19PM -0500
References:  <Pine.LNX.4.30.0104181723500.4364-100000@wiggum.isp.nwu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
I use something like this:

    find blah.... | xargs perl -pi -e 's/a-string/b-string/g'

John Capo

Quoting Laurence Berland (laurence@isp.northwestern.edu):
> If I've got a bunch of files, that I can list using find, what is the best
> way, using perl, to substitute every instance of a string with a different
> string in all these files.
> 
> Basically I want to run s/a-string/b-string/g in place on each file.
> 
> Any ideas?  I have already hosed some files messing this up once, and
> don't want to risk doing it again.
> 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010418190751.A25209>