一文了解H3C交换机正则表达式过滤显示信息

一文了解H3C交换机正则表达式过滤显示信息

解决方案goocz2025-03-29 14:04:3429A+A-

功能简介

在执行display命令查看显示信息时,可以使用正则表达式来过滤显示信息,以便快速的找到自己关注的信息。


在display命令中通过输入[ | [ by-linenum ] { begin | exclude | include } regular-expression ]&<1-128>参数的方式来过滤显示。各关键字的含义如下:

· by-linenum:表示带行号显示。当多次使用正则表达式对显示信息过滤时,by-linenum参数只需要输入一次即可生效。不指定该参数时,表示不带行号显示。

· begin:显示特定行及其以后的所有行,该特定行必须包含指定正则表达式。

· exclude:显示不包含指定正则表达式的所有行。

· include:只显示包含指定正则表达式的所有行。

· &<1-128>:表示前面的参数最多可以输入128次。

正则表达式(regular-expression)为1~256个字符的字符串,区分大小写,它支持多种特殊字符,特殊字符的匹配规则如表所示。



2. 配置限制和指导

正则表达式的执行时间和正则表达式的复杂程度成正比,对于复杂的正则表达式,执行时间会比较长,如有需要,可按键终止

3. 配置举例

# 查看当前生效的配置中,从包含“line”字符串的行开始到最后一行的配置信息(该显示信息与设备型号以及用户的当前配置有关)。

display current-configuration | begin line

line class aux

user-role network-admin

#

line class vty

user-role network-operator

#

……略……

# 查看设备当前处于UP状态的接口概要信息。

display interface brief | exclude DOWN

Brief information on interfaces in route mode:

Link: ADM - administratively down; Stby - standby

Protocol: (s) - spoofing

Interface Link Protocol Primary IP Description

InLoop0 UP UP(s) --

NULL0 UP UP(s) --

Vlan1 UP UP 192.168.1.83


Brief information on interfaces in bridge mode:

Link: ADM - administratively down; Stby - standby

Speed: (a) - auto

Duplex: (a)/A - auto; H - half; F - full

Type: A - access; T - trunk; H - hybrid

Interface Link Speed Duplex Type PVID Description

XGE1/0/1 UP 10G(a) F(a) A 1

# 查看SNMP相关配置。

display current-configuration | include snmp

snmp-agent

snmp-agent community write private

snmp-agent community read public

snmp-agent sys-info version all

snmp-agent target-host trap address udp-domain 192.168.1.2 params securityname public

# 显示日志缓冲区中包含SHELL字符串且包含VTY字符串的日志。

display logbuffer | include SHELL | include VTY

%Sep 6 10:38:12:320 2018 Sysname SHELL/5/SHELL_LOGIN: VTY logged in from 169.254.100.171.

%Sep 6 10:52:32:576 2018 Sysname SHELL/5/SHELL_LOGOUT: VTY logged out from 169.254.100.171.

点击这里复制本文地址 以上内容由goocz整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

果子教程网 © All Rights Reserved.  蜀ICP备2024111239号-5