[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-developers] find and replace shell script
- Subject: Re: [cobalt-developers] find and replace shell script
- From: Bruce Timberlake <bruce.timberlake@xxxxxxx>
- Date: Fri Apr 5 12:18:28 2002
- Organization: Sun Microsystems, Inc.
- List-id: Discussion Forum for developers on Sun Cobalt Networks products <cobalt-developers.list.cobalt.com>
Matthew Nuzum wrote:
>
> Can anyone suggest a command that I can use in a shell script that will
> help me do a find and replace action on a couple of thousand XML files?
>
> I need to replace something like http://domain.com/images with just
> /images and it can occur several times in the same file.
>
> Unfortunately, due to the nature of XML, many of the files don't contain
> a single carriage return, just one very long line.
I don't know if sed has a problem with long lines or not, but you could
try this:
cat file.xml | sed "s/http\:\/\/domain\.com\/images/\/images/g" >
newfile.xml
(All the "\" are to "escape" the regular slashes, punctuation, etc, so
they won't be interpreted by the shell...) Then newfile.xml would be the
modified file with "/images" and file.xml would still be your original
data with the "http://domain.com/images"...
HTH!
--
Bruce Timberlake
Sun Cobalt Technology Engineer
Sun Microsystems, Inc.