在perl中使用sed?

asa*_*adz 2 sed

我想重用这里给出的代码,但我一直在理解使用sed

print "Sending to QRadar...\n";
# SSH To QRadar's Console and push out file + trigger update
`scp -i $qradar_ssh_key -o UserKnownHostsFile=$qradar_ssh_knownhosts -o StrictHostKeyChecking=no root\@$qradar_console:/store/configservices/staging/globalconfig/remotenet.conf .`;
`sed -i -e '/^SECULERT/d' remotenet.conf`;
`cat $seculert_qradar_list >> remotenet.conf`;
`scp -i $qradar_ssh_key -o UserKnownHostsFile=$qradar_ssh_knownhosts -o StrictHostKeyChecking=no remotenet.conf root\@$qradar_console:/store/configservices/staging/globalconfig/remotenet.conf`;
Run Code Online (Sandbox Code Playgroud)

我想知道sed这里在做什么。

小智 7

在给定的行中,

`sed -i -e '/^SECULERT/d' remotenet.conf`;
Run Code Online (Sandbox Code Playgroud)

-i标志表示sed正在remotenet.conf就地编辑并-e '/^SECULERT/d'删除所有以“SECULERT”开头的行。

  • 请注意,如果 `sed` 打印任何输出,它将被渲染到 Perl 源中并按原样使用。(这就是反引号的性质。) (2认同)