如何过滤华为交换机中的确切接口?

网络工程 转变 华为
2021-07-15 11:19:54

如何过滤华为交换机中的确切接口?

你看我用include GigabitEthernet0/0/1to过滤的时候,会得到很多GigabitEthernet0/0/1*接口:

<Z178A>dis interface brief | include GigabitEthernet0/0/1  
PHY: Physical
*down: administratively down
#down: LBDT down
(l): loopback
(s): spoofing
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(lb): LBDT block
InUti/OutUti: input utility/output utility
Interface                   PHY   Protocol  InUti OutUti   inErrors  outErrors
GigabitEthernet0/0/1        up    up           0%  0.01%          0          0
GigabitEthernet0/0/10       up    up        0.12%  0.13%          0          0
GigabitEthernet0/0/11       up    up           0%  0.01%          0          0
GigabitEthernet0/0/12       up    up           0%  0.01%          0          0
GigabitEthernet0/0/13       up    up        0.17%  0.03%          0          0
GigabitEthernet0/0/14       up    up           0%  0.01%          0          0
GigabitEthernet0/0/15       up    up           0%  0.01%          0          0
GigabitEthernet0/0/16       up    up           0%     0%          0       5281
GigabitEthernet0/0/17       down  down         0%     0%          0          0
GigabitEthernet0/0/18       down  down         0%     0%          0          0
GigabitEthernet0/0/19       down  down         0%     0%          0          0

当我使用时,GigabitEthernet0/0/1\s我无法过滤GigabitEthernet0/0/1掉。

<Z178A>dis interface brief | include GigabitEthernet0/0/1\s
PHY: Physical
*down: administratively down
#down: LBDT down
(l): loopback
(s): spoofing
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(lb): LBDT block
InUti/OutUti: input utility/output utility
Interface                   PHY   Protocol  InUti OutUti   inErrors  outErrors
<Z178A>

那么,谁能帮我解决这个问题?我想过滤掉确切的接口GigabitEthernet0/0/1


<Z178A>dis interface brief | ?                             
  begin    Begin with the line that matches
  exclude  Match the character strings excluding with the regular expression
  include  Match the character strings including with the regular expression

编辑-01

我试过了,display interface brief | i ^XGigabitEthernet0/0/1 +但还是不行。

[Z178A]display interface brief                       
PHY: Physical
*down: administratively down
#down: LBDT down
(l): loopback
(s): spoofing
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(lb): LBDT block
InUti/OutUti: input utility/output utility
Interface                   PHY   Protocol  InUti OutUti   inErrors  outErrors
Eth-Trunk1                  up    up        2.80%  2.60%          0          0
  GigabitEthernet0/0/49     up    up        2.92%  2.82%          0          0
  GigabitEthernet0/0/50     up    up        2.68%  2.38%          0          0
Eth-Trunk100                down  down         0%     0%          0          0
GigabitEthernet0/0/1        up    up           0%  0.04%          0          0
GigabitEthernet0/0/2        up    up           0%     0%          0          0
GigabitEthernet0/0/3        up    up           0%     0%          0          0
GigabitEthernet0/0/4        up    up        0.01%  0.01%          0          0
GigabitEthernet0/0/5        up    up           0%  0.02%          0          0
GigabitEthernet0/0/6        up    up           0%     0%          0          0
GigabitEthernet0/0/7        up    up           0%     0%          0          0
GigabitEthernet0/0/8        up    up           0%  0.04%          0          0
GigabitEthernet0/0/9        up    up           0%  0.04%          0          0
GigabitEthernet0/0/10       up    up        0.08%  0.06%          0          0
GigabitEthernet0/0/11       up    up           0%  0.01%          0          0
GigabitEthernet0/0/12       up    up           0%     0%          0          0
GigabitEthernet0/0/13       up    up        0.07%  0.02%          0          0
GigabitEthernet0/0/14       up    up        0.08%  0.02%          0          0
GigabitEthernet0/0/15       up    up           0%  0.04%          0          0
GigabitEthernet0/0/16       up    up           0%     0%          0       5281
GigabitEthernet0/0/17       down  down         0%     0%          0          0
GigabitEthernet0/0/18       down  down         0%     0%          0          0
GigabitEthernet0/0/19       down  down         0%     0%          0          0
GigabitEthernet0/0/20       down  down         0%     0%          0          0
GigabitEthernet0/0/21       down  down         0%     0%          0          0
GigabitEthernet0/0/22       down  down         0%     0%          0          0
GigabitEthernet0/0/23       down  down         0%     0%          0          0
GigabitEthernet0/0/24       down  down         0%     0%          0          0
GigabitEthernet0/0/25       down  down         0%     0%          0          0
GigabitEthernet0/0/26       down  down         0%     0%          0          0
GigabitEthernet0/0/27       down  down         0%     0%          0          0
GigabitEthernet0/0/28       down  down         0%     0%          0          0
GigabitEthernet0/0/29       down  down         0%     0%          0          0
GigabitEthernet0/0/30       down  down         0%     0%          0          0
GigabitEthernet0/0/31       down  down         0%     0%          0          0
GigabitEthernet0/0/32       down  down         0%     0%          0          0
GigabitEthernet0/0/33       down  down         0%     0%          0          0
GigabitEthernet0/0/34       down  down         0%     0%          0          0
GigabitEthernet0/0/35       down  down         0%     0%          0          0
GigabitEthernet0/0/36       down  down         0%     0%          0          0
GigabitEthernet0/0/37       up    up           0%     0%          0          0
GigabitEthernet0/0/38       up    up           0%     0%          0          0
GigabitEthernet0/0/39       up    up           0%     0%          0          0
GigabitEthernet0/0/40       up    up           0%     0%          0          0
GigabitEthernet0/0/41       up    up           0%     0%          0          0
GigabitEthernet0/0/42       up    up           0%     0%          0          0
GigabitEthernet0/0/43       up    up        4.94%  5.34%          0          0
GigabitEthernet0/0/44       up    up           0%     0%          0          0

[Z178A]display interface brief  | i ^XGigabitEthernet0/0/1 +  
PHY: Physical
*down: administratively down
#down: LBDT down
(l): loopback
(s): spoofing
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(lb): LBDT block
InUti/OutUti: input utility/output utility
Interface                   PHY   Protocol  InUti OutUti   inErrors  outErrors
1个回答

貌似华为CLI支持正则表达式,所以接口名称后匹配一个或多个空格是最好的选择。

在我的交换机上:

<Huawei>display interface brief  | i ^XGigabitEthernet0/0/1 +
PHY: Physical
*down: administratively down
#down: LBDT down
(l): loopback
(s): spoofing
(E): E-Trunk down
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(lb): LBDT block
InUti/OutUti: input utility/output utility
Interface                   PHY   Protocol  InUti OutUti   inErrors  outErrors
XGigabitEthernet0/0/1       up    up        0.02%  0.02%          0          0

其中^匹配行的开头(我认为您可以省略这一点),而<space>+表示“匹配_一个或多个空格”。