在文件中搜索字符串,然后找到与不同字符串

时间:2017-05-08 21:08:35

标签: awk sed grep

我有一些硬件负载均衡器配置,我想使用任何可用的linux工具(例如sed,awk,grep等)进行解析。

我想搜索短语address 10.1.104.164,我想知道它所在的池。例如,如果我们搜索10.1.104.164,我希望它返回:

ltm pool pool_10.1.105.30_80
ltm pool pool_10.1.105.31_80

以下是我正在搜索的文件示例:

ltm pool pool_10.1.105.30_80 {
    load-balancing-mode observed-member
    members {
        node_10.1.104.163:http {
            address 10.1.104.163
            session monitor-enabled
            state up
        }
        node_10.1.104.164:http {
            address 10.1.104.164
            session monitor-enabled
            state up
        }
    }
    monitor http_200_OK
}
ltm pool pool_10.1.105.31_80 {
    load-balancing-mode observed-member
    members {
        node_10.1.104.163:http {
            address 10.1.104.163
            session monitor-enabled
            state up
        }
        node_10.1.104.164:http {
            address 10.1.104.164
            session monitor-enabled
            state up
        }
    }
    monitor http_200_OK
}

提前致谢, 克里斯

编辑:拼写和格式化。

2 个答案:

答案 0 :(得分:1)

ifEqual = [string1 compare:string2] == NSOrderedSame;

答案 1 :(得分:1)

使用import aiohttp connector = aiohttp.TCPConnector(limit_per_host=50) client = aiohttp.ClientSession(connector=connector)

perl