Operating System - HP-UX
1837981 Members
1891 Online
110124 Solutions
New Discussion

Need help writing script with vi

 
SOLVED
Go to solution
Guilherme Belinelo
Occasional Advisor

Need help writing script with vi

Hi,

Can someone help me in replacing a word in several ascii files within a folder? What I need to do is replace the word cgi.exe for cgi in html pages.
3 REPLIES 3
Rainer_1
Honored Contributor
Solution

Re: Need help writing script with vi

you can use a little script

for file in *.html
do
sed -e 's/cgi.exe/cgi/g' $file >$file.tmp
mv $file.tmp $file
done
Guilherme Belinelo
Occasional Advisor

Re: Need help writing script with vi

Thank you Rainer, that is just what I need.
Leslie Chaim
Regular Advisor

Re: Need help writing script with vi

If you have perl available this is more consice:

perl -pi -e 's/cgi.exe/cgi/g' *.html

Perl will do all the magic for you.
If life serves you lemons, make lemonade