Date: 18 Apr 2001 22:40:08 -0500 From: Tim Ayers <tayers@bridge.com> To: questions@FreeBSD.ORG Subject: Re: OT:Use perl to substitute a string for another in many files Message-ID: <uelupeew7.fsf@tim.bridge.com> In-Reply-To: <20010418190751.A25209@tortugas.irbs.com> References: <Pine.LNX.4.30.0104181723500.4364-100000@wiggum.isp.nwu.edu> <20010418190751.A25209@tortugas.irbs.com>
next in thread | previous in thread | raw e-mail | index | archive | help
For an extra margin of safety you can give the -i option a parameter and then Perl will make backup copies of all the files. For example find blah.... | xargs perl -pi '.bak' -e 's/a-string/b-string/g' Hope you have a very nice day, :-) Tim Ayers (tayers@bridge.com) >>>>> "J" == John Capo <jc@irbs.com> writes: J> I use something like this: J> find blah.... | xargs perl -pi -e 's/a-string/b-string/g' J> John Capo J> 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. >> J> To Unsubscribe: send mail to majordomo@FreeBSD.org J> 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?uelupeew7.fsf>