我有一个脚本可以清理作为参数提供的文件中的模式。
需要清理的“file1”和脚本位于同一位置。当我将“file1”作为参数传递时,回显良好,但在 执行 sed 命令时出现以下错误:
-sh-3.2$ ./temp.pl file1.txt
File provided as the argument : file1.txt
sed: no input files
我的脚本是:
my $logfile = $ARGV[0];
print "File provided as the argument : $logfile \n";
$cmd = q(sed -i '/Job will shutdown./d' $logfile);
$n = system($cmd);
最佳答案
更改您的报价系统:
$cmd = "sed -i '/Job will shutdown./d' $logfile";
或者:
$cmd = qq(sed -i '/Job will shutdown./d' $logfile);
检查http://www.perlmonks.org/?node=quotes+in+Perl
PD:此任务可以在 perl
中本地完成。
关于perl - Sed错误 "sed: no input files",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29599798/