Ok, that's just plain sexy.
Off to the bookstore to get Learning Perl!
Geordon
----- Original Message -----
From: "Tara L Andrews"
On Thu, Apr 26, 2001 at 09:35:09PM -0500, Timothy R.Butler wrote:
Hi everyone,
I'm looking for a way to replace every instance of a certain text string in about nine files. What's more, what I'm looking for preferably needs to replace these items recusively, as I have the aformentioned string in a directory, and it's subdirectory.
Any ideas? For some reason I have the feeling I am going to need to get to know "sed." <rant>If only I could get a version of UltraEdit for Linux, I wouldn't have this problem... :-( Unfortunately I can't find a text editor for Linux that has a multi-document interface/project interface, so it can do a "Replace in all Project files."</rant>
Alternatively, you could get to know perl. :)
find . -type f -exec perl -ni.bak e 's/old text string/new string of text/g; print' {} \;
(or \{\} \; at the end, to be perfectly safe)
Breakdown for those unfamiliar with the command(s): finds all files that are regular files (not directories or symlinks, etc.) in the current directory (.) and executes the perl command on each file found.
The perl says "On each line of a file, saving a backup in filename.bak, replace (switch, hence the 's') every occurrence of 'old text string' with 'new text string', more than once per line if you have to. Then print the line."
-tara
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq and the archives at http://lists.suse.com