3

How can I filter the exact interface in huawei switch?

you see when I use the include GigabitEthernet0/0/1 to filter, there will get many GigabitEthernet0/0/1* interfaces:

<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

when I use the GigabitEthernet0/0/1\s I can not filter the GigabitEthernet0/0/1 out.

<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>

so, who can help me with this? I want to filter out the exact interface 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

EDIT-01

I tried the display interface brief | i ^XGigabitEthernet0/0/1 + but still not work.

[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
5
  • dis interface brief | include GigabitEthernet0/0/1$. $ means the end of the line. It will work if Huawei fully supports regular expressions. May 15, 2019 at 5:53
  • I tried this, not work.
    – 244boy
    May 15, 2019 at 6:22
  • Ah. How about dis interface brief | exclude 1[0-9] or dis interface brief | include \w*0\/0\/1\b\s+ May 15, 2019 at 6:34
  • there will filter out the 2*.
    – 244boy
    May 15, 2019 at 6:35
  • Next solution dis interface brief | exclude \/[2-9]|\/[0-9]{2} May 15, 2019 at 6:53

1 Answer 1

4

Looks like Huawei CLI supports Regular Expressions, so matching one or more spaces after the interface name is your best bet.

On my switch:

<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

Where the ^ matches the start of the line (you can omit this, I think), while <space>+ means "match _one or more spaces".

2
  • it do not work too, see my edited post.
    – 244boy
    Jun 3, 2019 at 3:23
  • @244boy In your case the interfaces are not 10GbE, so you should use ^GigabitEthernet and not ^XGigabitEthernet Jun 3, 2019 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.