I have been trying to replace a string:
This-ismy-oldstring
to
This-ismy-newstring
on a unix box
underneath a directory, which contain files and subdirectories containing
other files, which have my This-ismy-oldstring. I need to make a global
replacement substituting This-ismy-oldstring to This-ismy-newstring
I have managed to do it opening a single file, but I need to do it in
multiple files. What is a good approach to accomplish this task? I was
thinking in doing a use:
Shell qw (ls);
$main_dir_contents=ls ( "-R");
and somehow make the script to do a for loop, i.e for i in
$main_dir_contents, open it and make the replacement. Please, help... I am
a beginner and I would like to get this accomplished. Please, let me know
your ideas.
Part of my scripts looks as follows:
open(FH, "+</etc/inetd.conf");
while(<FH>) {
if($_=~s/^\#(shell\s.*\sin.rshd)$/$1/){
chomp($line=$_);
$currentpos=tell;
}
}
$currentpos=$currentpos-72;
seek(FH,$currentpos,0);
print FH " $line";
Yanet I. Leon
Unix System Administrator
EDS - Defense Manpower Data Center
400 Gigling Road
Seaside, CA 93955-6771
Phone#: (831)583-2400 ext. 4351
Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]