【发布时间】:2019-09-27 20:49:41
【问题描述】:
如果下一行与模式匹配,我将无法删除下一行。 例如:
define service{
host_name A
notification_period F
}
define service{
host_name A
notification_period metrologie
notification_period F
}
我检查模式计量。如果下一行包含notification_period,我想删除行notification_period F。
我尝试使用命令 sed '/metrologie/{h;d;};/notification_period/{x;!d;}' $file
但它将字符串转换为:
define service{
host_name A
}
define service{
host_name A
notification_period metrologie
}
我想要这个输出:
define service{
host_name A
notification_period F
}
define service{
host_name A
notification_period metrologie
}
【问题讨论】:
标签: sed