Проект

Общее

Профиль

Действия

Sed

Добавление строк в секции (range)

sed -e '/define  service/,/\(\}\|\<use\>\)/{/\}/i\' -e 'use base' -e '}' file

Было

define  service {
    host_name            do.kemerovo.lenina82
    service_description        ping loopback
    use                                base,ping_loopback
    check_command            ubrr_check_ping_far
    register            1
    }    
define  service {
    host_name            do.kemerovo.lenina82
    service_description        ping ubrr tun295 [e-lite] 10.10.50.133
    check_command            check_address_alive!10.10.50.133
    notification_options        c,r,f
    register            1
    }    
define  service {
    host_name            do.kemerovo.lenina82
    service_description        ping ubrr tun296 [zsttk] 10.10.250.49
    check_command            check_address_alive!10.10.250.49
    notification_options        c,r,f
    register            1
    }

Стало

define  service {
    host_name            do.kemerovo.lenina82
    service_description        ping loopback
    use                                base,ping_loopback
    check_command            ubrr_check_ping_far
    register            1
    }    
define  service {
    host_name            do.kemerovo.lenina82
    service_description        ping ubrr tun295 [e-lite] 10.10.50.133
    check_command            check_address_alive!10.10.50.133
    notification_options        c,r,f
    register            1
    use                             base
    }    
define  service {
    host_name            do.kemerovo.lenina82
    service_description        ping ubrr tun296 [zsttk] 10.10.250.49
    check_command            check_address_alive!10.10.250.49
    notification_options        c,r,f
    register            1
    use                             base
    }

Обновлено Андрей Волков больше 10 лет назад · 1 изменени(я, ий)