From owner-freebsd-questions Wed Nov 11 15:34:55 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA18706 for freebsd-questions-outgoing; Wed, 11 Nov 1998 15:34:55 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from ccsales.com (ccsales.com [216.0.22.30]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA18683 for ; Wed, 11 Nov 1998 15:34:50 -0800 (PST) (envelope-from randyk@ccsales.com) Received: from ntrkcasa (b226.ecom.net [207.13.225.226]) by ccsales.com (8.9.1/8.9.0) with SMTP id PAA03642; Wed, 11 Nov 1998 15:33:09 -0800 (PST) Message-Id: <3.0.5.32.19981111153402.037d6570@ccsales.com> X-Sender: randyk@ccsales.com X-Mailer: QUALCOMM Windows Eudora Pro Version 3.0.5 (32) Date: Wed, 11 Nov 1998 15:34:02 -0800 To: chuck@ucsd.edu, Zdenko Tomasic From: "Randy A. Katz" Subject: Re: find and replace within files. Cc: fabry@panam.edu, freebsd-questions@FreeBSD.ORG In-Reply-To: References: <9811112006.AA02973@CS.UH.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello, in PERL: #!/usr/bin/perl open(FILE1,"myfile.txt"); open(FILE2,">mynewfile.txt"); while () { s/My Little Text/Replaced With/g; print FILE2; } close(FILE1); close(FILE2); This will replace all instances of My Little Text with Replaced With and write it all out to FILE2 (mynewfile.txt). You can use regular expressions also in the s///; structure... At 02:57 PM 11/11/98 -0800, Chuck Rouillard wrote: >On Wed, 11 Nov 1998, Zdenko Tomasic wrote: > >> Take a look at perl. It is probably the most convenient tool for that. >> (I think it could be done as a 1-liner). >> >> ZT >> >> To Unsubscribe: send mail to majordomo@FreeBSD.org >> with "unsubscribe freebsd-questions" in the body of the message > >Perl or AWK. Perl especially. > > > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-questions" in the body of the message > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message