No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search

Reminder

To have a better experience, please upgrade your IE browser.

upgrade

Configuration Guide - Basic Configuration

S7700 and S9700 V200R010C00

This document describes methods to use command line interface and to log in to the device, file operations, and system startup configurations.
Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Filtering Output Information Based on the Regular Expression

Filtering Output Information Based on the Regular Expression

Regular Expressions

When you run the display command to check the device configuration and running status information, you can filter out unnecessary information based on the regular expression.

A regular expression is a mode matching tool. You can create a matching mode based on specified rules and then match target objects based on the matching mode. A regular expression consists of 1 to 256 common characters and special characters.

  • Common characters

    Common characters are used to match themselves in a string, including all upper-case and lower-case letters, digits, punctuations, underline, and special symbols. For example, a matches the letter "a" in "abc", 20 matches the digit "20" in "20.1.1.1", and @ matches the symbol "@" in "xxx@xxx.com".

  • Special characters

    Special characters are a set of symbols with special meanings which are provided to flexibly create matching modes. The special characters are also called metacharacters. Table 1-4 describes special characters and their syntax.

    Table 1-4  Description of special characters

    Special Characters

    Function

    Example

    \

    Defines an escape character, which is used to mark the next character (common or special) as the common character.

    \* matches "*".

    ^

    Matches the starting position of the string.

    ^10 matches "10.10.10.1" instead of "20.10.10.1".

    $

    Matches the ending position of the string.

    1$ matches "10.10.10.1" instead of "10.10.10.2".

    *

    Matches the preceding element zero or more times.

    10* matches "1", "10", "100", "1000", and so on.

    (10)* matches "null", "10", "1010", "101010", and so on.

    +

    Matches the preceding element one or more times.

    10+ matches "10", "100", "1000", and so on.

    (10)+ matches "10", "1010", "101010", and so on.

    ?

    Matches the preceding element zero or one time.

    NOTE:

    Huawei data communication devices do not support regular expressions with ?. When regular expressions with ? are entered on Huawei data communication devices, helpful information is provided.

    10? matches "1" or "10".

    (10)? matches "null" or "10".

    .

    Matches any single character.

    0.0 matches "0x0", "020", and so on.

    .oo. matches "book", "look", "tool", and so on.

    ()

    Defines a subexpression, which can be null. Both the expression and the subexpression should be matched.

    100(200)+ matches "100200", "100200200", and so on.

    x|y

    Matches x or y.

    100|200 matches "100" or "200".

    1(2|3)4 matches "124" or "134", instead of "1234", "14", "1224", and "1334".

    [xyz]

    Matches any single character in the regular expression.

    [123] matches the character 2 in "255".

    [^xyz]

    Matches any character that is not in the regular expression.

    [^123] matches any character except for "1", "2", and "3".

    [a-z]

    Matches any character within the specified range.

    [0-9] matches any character ranging from 0 to 9.

    [^a-z]

    Matches any character beyond the specified range.

    [^0-9] matches all non-numeric characters.

    A simple regular expression does not contain any special character. For example, you can create a simple regular expression "hello" to match the character string "hello" only. In practice, multiple common and special characters are used together to match a character string with special features.

  • Degeneration of special characters

    Certain special characters, when placed at certain positions in a regular expression, degenerate to common characters.

    • The special characters following "\" match special characters themselves.

    • The special characters "*", "+", and "?" are placed at the starting position of the regular expression. For example, +45 matches "+45" and abc(*def) matches "abc*def".

    • The special character "^" is placed at any position except for the start of the regular expression. For example, abc^ matches "abc^".

    • The special character "$" is placed at any position except for the end of the regular expression. For example, 12$2 matches "12$2".

    • A right parenthesis ")" or right bracket "]" is not paired with a corresponding left parenthesis "(" or bracket "[". For example, abc) matches "abc)" and 0-9] matches "0-9]".

    NOTE:

    Unless otherwise specified, degeneration rules also apply when the preceding regular expressions are subexpressions within parentheses.

Usage of Regular Expressions

There are two modes to filter output information based on the regular expression.
  • Specifying a filtering mode in a command: enter the keyword begin, exclude, or include, and a regular expression in the command line to filter command outputs.
  • Specifying a filtering mode on a split screen: enter a slash (/), minus (-), or plus (+) symbol, and a regular expression to filter command outputs to be displayed on a split screen. The slash (/), minus (-), and plus (+) symbols have the same functions as the keywords begin, exclude, and include.

Specifying a Filtering Mode in a Command

Three filtering modes are provided for commands that support regular expressions.

  • | begin regular-expression: displays all the lines beginning with the line that matches the regular expression.

    Filter the character strings to be entered until the specified case-sensitive character string is displayed. All the character strings following this specified character string are displayed on the screen.

  • | exclude regular-expression: displays all the lines that do not match the regular expression.

    If the character strings to be entered do not contain the specified case-sensitive character string, they are displayed on the screen. Otherwise, they are filtered.

  • | include regular-expression: displays all the lines that match the regular expression.

    If the character strings to be entered contain the specified case-sensitive character string, they are displayed on the screen. Otherwise, they are filtered.

NOTE:

You can specify the filtering mode of output information for some display commands that have large amount of output information.

After the command output is filtered, the displayed information is displayed with its context. Context rules are as follows:
  • before before-line-number: displays lines that match filtering rules and the preceding before-line-number lines.

  • after after-line-number: displays lines that match filtering rules and the subsequent after-line-number lines.

  • before before-line-number + after after-line-number or after after-line-number + before before-line-number: displays lines that match filtering rules, the preceding before-line-number lines, and the subsequent after-line-number lines.

    Values of before-line-number and after-line-number are a string of 1 to 999 characters.

The following examples describe how to specify a filtering mode in a command.

Example 1: Run the display interface brief command to display all the lines that do not match Ethernet, NULL, or Tunnel.

<HUAWEI> display interface brief | exclude Ethernet|NULL|Tunnel
PHY: Physical
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(d): Dampening Suppressed
InUti/OutUti: input utility/output utility
Interface                   PHY   Protocol InUti OutUti   inErrors  outErrors
Eth-Trunk1                  down  down        0%     0%          0          0
Eth-Trunk17                 down  down        0%     0%          0          0
LoopBack1                   up    up(s)       0%     0%          0          0
Vlanif1                     up    down        --     --          0          0
Vlanif2                     down  down        --     --          0          0
Vlanif10                    down  down        --     --          0          0
Vlanif12                    down  down        --     --          0          0
Vlanif13                    down  down        --     --          0          0
Vlanif20                    up    up          --     --          0          0
Vlanif22                    down  down        --     --          0          0
Vlanif222                   down  down        --     --          0          0
Vlanif4094                  down  down        --     --          0          0

Example 2: Run the display current-configuration command to display all the lines that match the regular expression vlan.

<HUAWEI> display current-configuration | include vlan
vlan batch 2 10 101 to 102 800 1000
vlan 2
vlan 10
 port trunk pvid vlan 800
 undo port trunk allow-pass vlan 1
 port trunk allow-pass vlan 10 101 800
 undo port hybrid vlan 1
 undo port hybrid vlan 1
 port hybrid untagged vlan 10
 undo port hybrid vlan 1
 undo port hybrid vlan 1
NOTE:

The command output provided here is used for reference only. The actual output information may differ from the preceding information.

Specifying a Filtering Mode on a Split Screen

When the output of the following commands is displayed screen by screen, you can specify a filtering mode:
  • display current-configuration
  • display interface
  • display arp

When a lot of information is displayed on a split screen, you can specify a filtering mode in the prompt "---- More ----".

  • /regular-expression: displays all the lines beginning with the line that matches the regular expression.

  • -regular-expression: displays all the lines that do not match the regular expression.

  • +regular-expression: displays all the lines that match the regular expression.

For example, run the display current-configuration command to display only VLANIF-related information when the command output is displayed on a split screen.
<HUAWEI> display current-configuration
!Software Version V200R010C00
#
sysname HUAWEI
#
vlan batch 10 to 11 100
#
hotkey CTRL_G "display tcp status"
#
lldp enable
#
undo http server enable
undo http secure-server enable
#
dhcp enable
#
dhcp snooping enable
+Vlanif            //Enter the filtering mode.

Filtering...
interface Vlanif10
interface Vlanif100
Translation
Download
Updated: 2019-04-18

Document ID: EDOC1000141895

Views: 51938

Downloads: 210

Average rating:
This Document Applies to these Products
Related Documents
Related Version
Share
Previous Next