特殊文字({&})の間にパターンマッチングが発生する必要がある場合は、特殊文字間にデータを印刷するにはSed / awkコマンドが必要です。
次のファイルがあります。
define service {
host_name dns_vips
service_description Multi Lookup
use standard_service_template
active_checks_enabled 1
passive_checks_enabled 1
notifications_enabled 1
contact_groups mailgrp
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
notification_interval 10
check_period 24x7
notification_period 24x7
notification_options w,r,c
}
define service {
host_name dns_vips1
service_description Multi Lookup 2
use standard_service_template
active_checks_enabled 1
passive_checks_enabled 1
notifications_enabled 1
contact_groups mailgrp1
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
notification_interval 10
check_period 24x7
notification_period 24x7
notification_options w,r,c
}
{
多重照会を通じて期間と期間のデータを照合するためのサービス記述が必要です。}
ベストアンサー1
sed '
/{/{ #starts next code block if line include «{»
:1 #set mark point
/}/!{ #execute if pattern (collected lines) do not include «}»
N #add next line to the pattern space
b1 #return to marked point
} #end of second (inner) block of code
} #end of first block of code
/Multi Lookup/p #prints pattern (collected lines) if it has «Multi Lookup»
d #clean pattern (start from the beginning)
' file