通过搜索单个单词或多个单词来获取整个段落

通过搜索单个单词或多个单词来获取整个段落

我需要你在脚本部分的帮助。

我有一个路由器的配置文件,如下所示,

# TiMOS-C-16.0.R5-1 cpm/hops64 Nokia 7750 SR Copyright (c) 2000-2019 Nokia.

# All rights reserved. All use subject to applicable license agreements.

# Built on Fri Jan 18 10:59:23 PST 2019 by builder in /builds/c/160B/R5-1/panos/main


# Generated MON SEP 30 08:06:41 2019 UTC

exit all
configure
#--------------------------------------------------
echo "System Configuration"
#--------------------------------------------------
    system
        name "iLAB-SR-12-R2"
        ptp
            profile g8275dot1-2014
            clock-type boundary
        exit
        rollback
            rollback-location "cf3:/rollback"
        exit
        snmp
            streaming
                no shutdown
            exit
            packet-size 9216
        exit
        software-repository "SAS-Sx-image" create
            description "Ethernet Satellite SW rep"
            primary-location "cf3:\images\7210-SAS-Sx-TiMOS-10.0.R10"
        exit
        time
            ntp
                ntp-server authenticate
                authentication-key 1 key "9MwhaEG2ryE/jYWFp7Sa64ypYoc=" hash2 type message-digest
                no shutdown
            exit
            sntp
                shutdown
            exit
            zone SGT 08
        exit

#--------------------------------------------------
echo "System Time NTP Configuration"
#--------------------------------------------------
    system
        time
            ntp
                server ptp prefer
                server 129.250.35.251
            exit
        exit
    exit

所以大多数路由器都有上面的配置文件。

现在我有一些关键的块文件如下,

time
    ntp
        ntp-server authenticate
        authentication-key 1 key "9MwhaEG2ryE/jYWFp7Sa64ypYoc=" hash2 type message-digest
        no shutdown
    exit
    sntp
        shutdown
    exit
    zone SGT 08
exit

ptp
    profile g8275dot1-2014
    clock-type boundary
exit


    system
        login-control
            idle-timeout 60
        exit
    exit


system
    time
        ntp
            server ptp prefer
            server 129.250.35.251
        exit
    exit
exit

因此,我想检查所有关键块文件与路由器配置,以确定所有关键块文件都存在于路由器配置中。

我已经卡住了。任何人都可以帮忙给出解决方案。我是否可以使用 awk、sed 或 grep 或任何其他工具。

你的帮助将是非常可观的。谢谢。

相关内容