Use this from unix prompt : sed s/fox/coyote/g test.txt > tmp
--Jay -----Original Message----- From: Mr Mojo [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 10, 2004 1:57 PM To: [EMAIL PROTECTED] Subject: Replace a string in a text file Hello, I have a text file (texst1.txt) that reads: The quick brown fox jumped over the lazy dog. I would like to replace the word fox with coyote. Is there an easier/simpler/cooler way to do this? #!/usr/bin/perl -w use strict; open (FILE, "test1.txt"); open (NEWFILE, ">>tmp"); while (<FILE>) { if ($_ =~ /fox/) { s/fox/coyote/; } print NEWFILE $_; } close FILE; close NEWFILE; unlink "test1.txt"; rename "tmp", "test1.txt"; Thanks, Greg -- ______________________________________________ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>