2

I have the script which cleans up the the pattern in the file supplied as the argument.

The "file1" that needs clean up and the script lies at the same place.When I pass "file1" as argumenit is echoed well but at the time of the execution of the sed command it gives the following error:

-sh-3.2$ ./temp.pl file1.txt

File provided as the argument : file1.txt
sed: no input files

My script is:

my $logfile = $ARGV[0];
print "File provided as the argument : $logfile \n";
$cmd = q(sed -i '/Job will shutdown./d' $logfile);
$n = system($cmd);
legends2k
  • 31,634
  • 25
  • 118
  • 222
user3616128
  • 357
  • 2
  • 5
  • 19

1 Answers1

4

Changue your quoting system:

$cmd = "sed -i '/Job will shutdown./d' $logfile";

Or:

$cmd = qq(sed -i '/Job will shutdown./d' $logfile);

Check http://www.perlmonks.org/?node=quotes+in+Perl

PD: This task could be done natively in perl.

Juan Diego Godoy Robles
  • 14,447
  • 2
  • 38
  • 52
  • 2
    Upvoted for advising on avoiding an additional tool. In fact this is one of the strong suits of Perl. – legends2k Apr 13 '15 at 07:25