I am trying to modify a perl script to comment out all lines matching some pattern. In normal command prompt, here is the line I'm trying to add:
grep -lIRZ --exclude="*\.svn*" "pattern" . | xargs -0 -l sed -i -e 's/.*pattern.*/\/\/&/g'
Here it is in the context of the perl script:
my $rmcmd = "grep -lIRZ --exclude=\"*\\.svn*\" \"pattern\" . | xargs -0 -l sed -i -e 's/.*pattern.*/\\/\\/&/g'";
runcmd($rmcmd);
...
sub runcmd {
my @cmd = @_;
print "Running: @cmd\n";
system(@cmd);
# Get status from system
my $ret = $? >> 8;
if ($ret) {
print "-E- command completed with error code $ret.\n";
exit(1);
}
return ($ret);
}
Everything works properly when run from a command prompt, but the script running the same command always crashes.
What is being done differently and how can I fix it?
在$ rmcmd = ..行末尾重新插入缺少的分号后,您的代码对我有用-在Ubuntu上使用perl 5.10.1。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.