Simplifying entry of commands at the command line
Do one or more of the following to simplify entry of commands:
To find or complete a command, use the [TAB] key. See Finding or completing a command.
To re-execute a command, use the
redo
command. See redo.To repeatedly re-execute one or more commands, use the
repeat
command. See repeat.To create a shortcut name for a command to simplify keystrokes, use the
alias
command. See alias.To simplify movement or placement of your cursor at the command line, use the shortcut keystrokes. See CLI shortcut keystrokes.
Finding or completing a command
Type one or more consecutive characters of a command and then press [Tab] (with no spaces allowed) to find a CLI command or to quickly complete a CLI command name. The CLI completes the current command name, including hyphenated extensions, if you have typed enough characters for the CLI to distinguish it from other possibilities.
The following example shows the result when you press [Tab] immediately after typing “t” at the Global Configuration level. The CLI displays the available command options that begin with “t”.
switch(config)# t tacacs-server telnet-server tftp time timesync trunk trunk-load-balance task-monitor telnet terminal test traceroute traceroute6
The following example shows the result when you press [Tab] immediately after typing “port-”.
switch (config)# port- switch (config)# port-security
The following example shows the result of pressing [Tab] after a completed command word lists the further options for that command. In this example, entering
switch(config)# qos[Tab]
displays the following:
switch (config)# qos udp-port Set UDP port-based priority. tcp-port Set TCP port-based priority. device-priority Configure device-based priority for a particular IP address. dscp-map Define mapping between a DSCP (Differentiated-Services Codepoint) value and an 802.1p priority. protocol Configure protocol-based priority. queue-config Configure the number of egress priority queues for each port. type-of-service Configure the Type-of-Service method the device uses to prioritize IP traffic. watch-queue Enables monitoring of per-queue dropped packets due to outbound congestion on the given port.
redo
Syntax
redo [ <number> | <command-str>
]
Description
Parameters/Options/Flags/Strings/...
The redo
command re-executes
a command. The last command that was used is executed by default.
Specifiers
| Specifies the position of the command in the history list. When the position is specified, the nth command starting from the most recent command in the history is executed. |
| Specifies the name of a previously executed command. The most recently executed command whose name matches the specified string is executed. |
Example
This example shows the use of the redo
command.
switch(config)# show history 2 show arp 1 show flash switch(config)# redo 2 IP ARP table IP Address MAC Address Type Port ------------- -------------- -------- ---- 15.255.128.1 00000c-07ac00 dynamic A11
repeat
Syntax
repeat [cmdlist] [count] [delay]
Description
The repeat
command repeatedly
re-executes one or more commands. By default, the most recent command
in the history is executed until a key is pressed.
Options
| Specifies the position of a command, or range of positions of multiple commands, in the history list. The nth most recent commands in the history, where "n" is the position in the history list, are re-executed. |
| Specifies number of times to execute the command or commands. |
| Specifies a delay. The execution of the command is delayed for the number of seconds specified. |
Usage
switch(config)# repeat 1-4,7-8,10 count 2 delay 3
Example
This demonstrates the use of the repeat
command
to re-execute commands that are at positions 1 through 2 in the command
history.
switch(config)# show history 3 show ver 2 show ip 1 show arp switch(config)# repeat 1-2 IP ARP table IP Address MAC Address Type Port -------------- ---------------- -------- ---- 15.255.128.1 000000-000000 dynamic Internet (IP) Service IP Routing : Disabled Default Gateway : Default TTL : 64 Arp Age : 20 Domain Suffix : DNS server : VLAN | IP Config IP Address Subnet Mask Proxy ARP ------------------ + ----------- --------------- -------------- --------- DEFAULT_VLAN | DHCP/Bootp 15.255.131.90 255.255.248.0 No No
alias
Syntax
[no] alias <name> <command>
Description
The alias
command creates
a shortcut alias name that can be used in place of a CLI command to
simplify keystrokes and aid memory. The alias
command
is executed from the current configuration context.
Options
Specifiers
| Specifies the alias for the CLI command. The alias name must not be an existing CLI command. |
| Specifies an existing CLI command for which to create the alias. The command must be enclosed in quotes. It is recommended that you use an alias that does not have an existing tab completion in the CLI. For example, using an alias that starts with "show" or "int" would complete to "show" and "interface" respectively when you use the tab completion function. |
Privilege
The alias
command is executed
from the current configuration context (operator, manager, or global).
If the command that is aliased has to be executed in the global configuration
context, you must execute the alias for that command in the global
configuration context. This prevents bypassing the security for a
particular context.
Restrictions
The alias name must not be an existing CLI command. Existing CLI commands are searched before looking for an alias command; an alias that is identical to an existing command will not be executed.
Hewlett Packard Enterprise recommends that you configure no more than 128 aliases.
Example
This example shows the creation and use of an
alias for the show int custom
command to demonstrate
how a command alias can simplify keystrokes when entering a command.
The actual show int custom
command is used first
and then an alias is created for it and then used.
switch(config)# show int custom 1-4 port name:4 type vlan intrusion speed enabled mdi Status and Counters - Custom Port Status Intrusion Port Name Type VLAN Alert Speed Enabled MDI-mode ---- -------- ---------- ----- --------- ------- ------- ------- 1 Acco 100/1000T 1 No 1000FDx Yes Auto 2 Huma 100/1000T 1 No 1000FDx Yes Auto 3 Deve 100/1000T 1 No 1000FDx Yes Auto 4 Lab1 100/1000T 1 No 1000FDx Yes Auto switch(config)# alias sic "show int custom 1-4 port name:4 type vlan intrusion speed enabled mdi" switch(config)# switch(config)# sic Status and Counters - Custom Port Status Intrusion Port Name Type VLAN Alert Speed Enabled MDI-mode ---- -------- ---------- ----- --------- ------- ------- ------- 1 Acco 100/1000T 1 No 1000FDx Yes Auto 2 Huma 100/1000T 1 No 1000FDx Yes Auto 3 Deve 100/1000T 1 No 1000FDx Yes Auto 4 Lab1 100/1000T 1 No 1000FDx Yes Auto
CLI shortcut keystrokes
Keystrokes | Functions |
---|---|
[Ctrl] [A] | Jumps to the first character of the command line. |
[Ctrl] [B] or ‘←’ | Moves the cursor back one character. |
[Ctrl] [C] | Terminates a task and displays the command prompt. |
[Ctrl] [D] | Deletes the character at the cursor. |
[Ctrl] [E] | Jumps to the end of the current command line. |
[Ctrl] [F] or ‘→’ | Moves the cursor forward one character. |
[Ctrl] [K] | Deletes from the cursor to the end of the command line. |
[Ctrl] [L] or [Ctrl] [R] | Repeats current command line on a new line. |
[Ctrl] [N] or ‘↓’ | Enters the next command line in the history buffer. |
[Ctrl] [P] or ‘↑’ | Enters the previous command line in the history buffer. |
[Ctrl] [U] or [Ctrl] [X] | Deletes from the cursor to the beginning of the command line. |
[Ctrl] [W] | Deletes the last word typed. |
[Esc] [B] | Moves the cursor backward one word. |
[Esc] [D] | Deletes from the cursor to the end of the word. |
[Esc] [F] | Moves the cursor forward one word. |
[Backspace] | Deletes the first character to the left of the curser in the command line. |
[Spacebar] | Moves the cursor forward one character. |