There are times where you need to specify the length and width of the terminal when issuing commands either to properly format the output to be parsed by scripts easier, or to eliminate the need to hit space or return when issuing commands that have multiple pages of output. Most of the time I will only change these if I am gathering output as a part of my script.
Below is an example of changing the length of the terminal, you can specify the terminal length up to 512 lines if you want more than that you will need to specify the terminal length of 0, which is unlimited lines of output. Setting the length to 0 will allow for the entire output of a command like ‘show run’ to be printed to the terminal in its entirety after issuing the command. Below is an example of setting the length to 0.
switch# terminal length 0
To reset the length of the terminal to its default issue the following command.
switch# terminal no length
The same concept applies to setting the terminal width, you can specify a width up to 512 columns, or if you want each intended line of output to display in its entirety on a single line versus automatically making line returns to fit properly in the terminal, you can set it to 0. The only times I have set the terminal width to 0 is for parsing output of commands like ‘show vlan’ which gives the vlan, name, status, and the ports that are assigned to that vlan displayed in a single line seperated by spaces. When the terminal width is set at its default it will make line returns after about 6 interfaces. For my scripts to parse this properly I need those ports on the same line, setting the terminal width to 0 before gathering that output will format it the way I need. Below is an example of setting the terminal width to 100.
switch# terminal width 100
And an example of resetting the terminal to its default width.
switch# terminal no width
A thing to keep in mind these commands only last for the session, so if you establish a new SSH session the terminal will be reset to defaults. If you want to check what your terminal length and width is set to at its current moment issue a ‘show terminal’ command and in the output you will see the terminal length and width among other information. You can see the length and width can be found on line 3 of the output below.
Line 1, Location: "", Type: "xterm"
Baud rate (TX/RX) is 9600/9600
Status: PSI Enabled, Ready, Active, No Exit Banner, Ctrl-c Enabled
Automore On, Notify Process
Modem state: Ready
Special Chars: Escape Hold Stop Start Disconnect Activation
^^x none - - none
Timeouts: Idle EXEC Idle Session Modem Answer Session Dispatch
00:15:00 never none not set
Idle Session Disconnect Warning
Login-sequence User Response
Autoselect Initial Wait
Modem type is unknown.
Session limit is not set.
Time since activation: 00:20:41
Editing is enabled.
History is enabled, history size is 20.
DNS resolution in show commands is enabled
Full user help is disabled
Allowed input transports are ssh.
Allowed output transports are telnet ssh.
Preferred transport is telnet.
Shell trace: off
No output characters are padded
No special data dispatching characters