Friday, October 8, 2010

Use Command Completion in Configuration Mode


The CLI command completion functions, described in Have the CLI Complete Commands, which refer to operational mode commands, also apply to the commands in configuration mode and to configuration statements. Specifically, to display all possible commands or statements, type the partial string followed immediately by a question mark, and to complete a command or statement that you have partially typed, press the tab key or spacebar.
Command completion also applies to identifiers, with one slight difference. To display all possible identifiers, type a partial string followed immediately by a question mark. To complete an identifier, you must press the tab key. This scheme allows you to enter identifiers with similar names; then press the spacebar when you are done typing the identifier name.

Have the CLI Complete Commands

You do not always have to remember or type the full command or option name for the CLI to recognize it. To display all possible command or option completions, type the partial command followed immediately by a question mark.
To complete a command or option that you have partially typed, press the tab key or the spacebar. If the partially typed letters begin a string that uniquely identifies a command, the complete command name appears. Otherwise, a beep indicates that you have entered an ambiguous command, and the possible completions are displayed.
Command completion also applies to other strings, such as filenames and usernames. To display all possible values, type a partial string followed immediately by a question mark. However, to complete these strings, press the tab key; pressing the space bar does not work.

Examples: Use CLI Command Completion

Issue the show interfaces command:
user@host> show i
`i' is ambiguous.
Possible completions:
    igmp                Show information about IGMP
    interface                Show interface information
    isis                Show information about IS-IS
user@host> show interfaces 
Physical interface: at-0/1/0, Enabled, Physical link is Up
  Interface index: 11, SNMP ifIndex: 65
  Link-level type: ATM-PVC, MTU: 4482, Clocking: Internal, SONET mode
  Speed: OC12, Loopback: None, Payload scrambler: Enabled
  Device flags   : Present Running
  Link flags     : 0x01
...
user@host>

Display a list of all log files whose names start with the string "messages," and then display the contents of one of the files:
user@myhost> show log mes?
Possible completions:
                                  Log file to display
  messages                                Size: 1417052, Last changed: Mar  3 00:33
  messages.0.gz                                Size: 145575, Last changed: Mar  3 00:00
  messages.1.gz                                Size: 134253, Last changed: Mar  2 23:00
  messages.10.gz                                Size: 137022, Last changed: Mar  2 14:00
  messages.2.gr                                Size: 137112, Last changed: Mar  2 22:00
  messages.3.gz                                Size: 121633, Last changed: Mar  2 21:00
  messages.4.gz                                Size: 135715, Last changed: Mar  2 20:00
  messages.5.gz                                Size: 137504, Last changed: Mar  2 19:00
  messages.6.gz                                Size: 134591, Last changed: Mar  2 18:00
  messages.7.gz                                Size: 132670, Last changed: Mar  2 17:00
  messages.8.gz                                Size: 136596, Last changed: Mar  2 16:00
  messages.9.gz                                Size: 136210, Last changed: Mar  2 15:00
user@myhost> show log messages.4.gz
Jan 15 21:00:00 myhost newsyslog[1381]: logfile turned over


No comments: