以下の詳細を含むヒューファイルがあります。
define host{
use generic-host ; Name of host template to use
host_name ServerA_172.29.16.102
alias ServerA_172.29.16.102
address 172.29.16.102
check_command check-host-alive
max_check_attempts 3
notification_interval 120
notification_period 24x7
}
define host{
use generic-host ; Name of host template to use
host_name ServerB_172.29.16.103
alias ServerB_172.29.16.103
address 172.29.16.103
check_command check-host-alive
max_check_attempts 3
notification_interval 120
notification_period 24x7
}
私が望むのは、"address 172.29.16.102"
5行上、4行後の4行を見つけて削除することです。
sedを試しましたが、うまくいきません
sed '$N;$N;N;/address 172.29.16.102/,+5d' hosts
ベストアンサー1
これは、各define_host
部分が1つ以上の改行で区切られている場合、GNU awkで発生する問題の種類とまったく同じです。複数行のレコードサポートは解決のためである
awk -v RS= '!/172.29.16.102/{printf $0""RT}'