Date: Wed, 11 Nov 1998 15:34:02 -0800 From: "Randy A. Katz" <randyk@ccsales.com> To: chuck@ucsd.edu, Zdenko Tomasic <zdenko@CS.UH.EDU> Cc: fabry@panam.edu, freebsd-questions@FreeBSD.ORG Subject: Re: find and replace within files. Message-ID: <3.0.5.32.19981111153402.037d6570@ccsales.com> In-Reply-To: <Pine.SUN.4.02A.9811111456480.9012-100000@sdcc10.ucsd.edu> References: <9811112006.AA02973@CS.UH.EDU>
next in thread | previous in thread | raw e-mail | index | archive | help
Hello, in PERL: #!/usr/bin/perl open(FILE1,"myfile.txt"); open(FILE2,">mynewfile.txt"); while (<FILE1>) { 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.5.32.19981111153402.037d6570>