我想僅打印接口Gigabitehternet有說明的行。我用:如何在多行上進行精確匹配linux
cat filter.txt | awk '/interface/ || /description/'
因此,作爲filter.txt的輸出,我想看到以下內容。
interface GigabitEthernet0/26
description test1
interface GigabitEthernet0/27
description test2
interface GigabitEthernet0/28
description test3
interface GigabitEthernet0/29
description test 4
tst:~$ cat filter.txt
interface Port-channel1
interface FastEthernet0
interface GigabitEthernet0/1
interface GigabitEthernet0/2
interface GigabitEthernet0/3
interface GigabitEthernet0/4
interface GigabitEthernet0/5
interface GigabitEthernet0/6
interface GigabitEthernet0/7
interface GigabitEthernet0/8
interface GigabitEthernet0/9
interface GigabitEthernet0/10
interface GigabitEthernet0/11
interface GigabitEthernet0/12
interface GigabitEthernet0/13
interface GigabitEthernet0/14
interface GigabitEthernet0/15
interface GigabitEthernet0/16
interface GigabitEthernet0/17
interface GigabitEthernet0/18
description test1
interface GigabitEthernet0/19
description test2
interface GigabitEthernet0/20
interface GigabitEthernet0/21
interface GigabitEthernet0/22
interface GigabitEthernet0/23
interface GigabitEthernet0/24
interface GigabitEthernet0/25
interface GigabitEthernet0/26
description test3
interface GigabitEthernet0/27
description test4
interface GigabitEthernet0/28
description test5
interface GigabitEthernet0/29
description test6
interface GigabitEthernet0/30
感謝您的幫助
大多數'接口GigabitEthernet0'在您需要的輸出沒有說明。 – SLePort