USAGE: perl "scriptname" "word to find" "word to replace" "file to which you are going to perform the action"
$find=$ARGV[0];
$replace=$ARGV[1];
$file= $ARGV[2];
open(FILE,"$file");
while($line=<FILE>)
{
if($line=~/bash/)
{
$line=~s/$find/$replace/;
print $line."\n";
}
else
{
print $line."\n";
}
}
close(FILE);
$find=$ARGV[0];
$replace=$ARGV[1];
$file= $ARGV[2];
open(FILE,"$file");
while($line=<FILE>)
{
if($line=~/bash/)
{
$line=~s/$find/$replace/;
print $line."\n";
}
else
{
print $line."\n";
}
}
close(FILE);
No comments:
Post a Comment