[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: script needed
- From: "Paul J. Bell" <paulb nomurany com>
- To: redhat-list redhat com
- Subject: Re: script needed
- Date: Thu, 01 Oct 1998 15:52:49 -0400
Paul J. Bell wrote:
> James Ervin wrote:
>
> > I have a site that has asked me to change all instances of a particular
> > link in all of their web pages.
> >
> > I can list all of the pages that need to be corrected with something like:
> >
> > grep -l badsite.html *.html
> >
> > this gives me a list of the files to edit.
> >
> > Are there any awk or shell scripting folks out there that can finish this
> > off with something that would work like this:
> >
> > grep -l badsite.html *.html | awk /s/badesite\.html/goodsite\.html/
> >
> > This may be way off base, but you should get the idea of what I am trying
> > to do.
> >
> > What I want to do is replace instances of badesite.html with the string
> > goodsite.html in the list of files generated by grep -l badsite.html *.html.
> >
> > end
> >
> > James Ervin
> > City of Bedford Network Administration
> > admin ci bedford va us
> > (540)586-7156
> >
>
> try something like:
>
> grep -l badsite.html *.html | sed 's/badsite.html/goodsite.html/' > foo.html
>
> sed is your friend (-:
>
> -paul
>
> when i look most closely at what you asked for, i can be more specific. try a
> scripts like this.
#!/bin/sh
for i in `grep -l badsite *.html` (note these are backticks - ` )
do
cat $i | sed 's/badsite/goodsite' >$i-new (these are forward ticks - ' )
echo "Changed $i"
done
the file names of the modified files will all have '-new' appended.
all of the original files will be unchanged.
if you want all of the files to have the -new appended, just replace the 'grep -l
good site *.html' with `ls *.html`
cheers,
-paul
>
--
"There is magic in the web" - Shakespeare (Othello, Act 3, Scene 4)
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]