Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Wed, 18 Feb 2004 16:00:18 -0800
From: Yitzchak Scott-Thoennes <sthoenna@efn.org>
To: cygwin@cygwin.com
Subject: Re: search and replace tool
Message-ID: <20040219000018.GA136@efn.org>
References: <291592011.20040218205953@thequod.de> <BAY12-DAV60bvKoq4bY000378bd@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <BAY12-DAV60bvKoq4bY000378bd@hotmail.com>
User-Agent: Mutt/1.4i
Organization: bs"d
X-IsSubscribed: yes

On Wed, Feb 18, 2004 at 12:13:38PM -0800, Rafael Kitover wrote:
> Not really cygwin specific, you can do something like:
> 
> perl -pi -e 's/old text/new text/' `find /where -name '*.txt'`
> 
> note those are backticks surrounding the find.
> 
> Use -pi.bak to make backup files in case you screw up. You will of course need
> to know how to use regular expressions (see man perlretut). If you need to do
> multiline replaces, you should probably write a script, or use some other
> solution.

Under cygwin, .bak is the default.  From perl's README.cygwin:
   Inplace editing C<perl -i> of files doesn't work without doing a backup
   of the file being edited C<perl -i.bak> because of windowish restrictions,
   therefore Perl adds the suffix C<.bak> automatically if you use C<perl -i>
   without specifying a backup extension.

Other options are sed or awk.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

