Mailinglist Archive: opensuse (3261 mails)

< Previous Next >
Re: [SLE] OT: I need to replace a certain string in a bunch of files
  • From: Gerhard den Hollander <gerhard@xxxxxxxxxxxx>
  • Date: Fri, 27 Apr 2001 09:18:33 +0200
  • Message-id: <20010427091830.J2382@xxxxxxxxxxxxx>
* Timothy R.Butler <tbutler@xxxxxxxxxxxxxxxxxxx> (Thu, Apr 26, 2001 at 09:35:09PM -0500)
> 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>
>
> <sigh>

find . -exec perl -pi -e 's/ORIGINALWORD/RAPLACEMENTWORD/;' {} \;

If you only want to do this in certaing files (say with a .html extension)
find . -name \*.html -exec perl -pi -e 's/ORIGINALWORD/RAPLACEMENTWORD/;' {} \;

If you only want to do this in files older than 10 days
find . -mtime +10 -exec perl -pi -e 's/ORIGINALWORD/RAPLACEMENTWORD/;' {} \;


find is your friend,
and perl rules.

If you feel like learning sed, don';t bother and start learning perl in
stead.

Kind regards,
--
Gerhard den Hollander Phone +31-10.280.1515
Technical Support Jason Geosystems BV Fax +31-10.280.1511
(When calling please note: we are in GMT+1)
gdenhollander@xxxxxxxxxxxx POBox 1573
visit us at http://www.jasongeo.com 3000 BN Rotterdam
JASON.......#1 in Reservoir Characterization The Netherlands

This e-mail and any attachment is/are intended solely for the named
addressee(s) and may contain information that is confidential and privileged.
If you are not the intended recipient, we request that you do not
disseminate, forward, distribute or copy this e-mail message.
If you have received this e-mail message in error, please notify us
immediately by telephone and destroy the original message.

< Previous Next >
References