小编asa*_*adz的帖子

在perl中使用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这里在做什么。

sed

2
推荐指数
1
解决办法
1148
查看次数

使用 awk 在第 5 行之后移动第 2 3 行

我的文件内容为:

this line 1 no un1x
this lines 22 0
butbutbut this 33 22 has unix
but not 1
THIS is not
butbutbut ffff
second line
Run Code Online (Sandbox Code Playgroud)
awk 'NR==2 && NR==3 {f=$0;next}  NR ==5 &&f{print;print f}' awk.write
Run Code Online (Sandbox Code Playgroud)

这里的问题是,f我只能保存nr==3我想在第 5 行之后移动第 2 行和第 3 行的值。

awk text-processing

1
推荐指数
1
解决办法
1074
查看次数

标签 统计

awk ×1

sed ×1

text-processing ×1