This article explains why the console CLI does not display the exact number of lines with the | last xxx option. The default screen width is 80 characters; if the output line exceeds 80 characters the line count will be off. A procedure is supplied for resetting the screen width, to accommodate longer output lines.
In most of the CLI operation commands, the | last xxx option can be used to display the last xxx number of lines. However, in certain outputs of console CLI operation commands, the last option displays fewer number of lines than expected.
This issue is due to the default console CLI screen-width, which is 80. This is the default screen width of the dump terminal. That is, the CLI will count one line, when the output stream contains 80 characters or a line feed control character is hit. If the output of CLI has a line that is longer than 80 characters, that line will be counted as two or more.
The first and second lines contains 92 and 93 characters respectively; so these two lines will be counted as two each, which makes it a total of four.
If the console is connected via a terminal emulation program and the screen width supports more than 80 characters, the default screen-width can be configured to the maximum characters that are supported by terminal emulation. So, the last option will display the correct number of lines.
The following example shows how to reset the screen width to accommodate longer output lines:
lab@srx210> set cli screen-width 147
Screen width set to 147
lab@srx210> show cli | match screen-width
CLI screen-width set to 147
lab@srx210> show security flow session |last 3 | no-more
In: xxx.xx.xx.134/787 --> xx.xxx.xx.235/23553;icmp, If: ge-0/0/0.0, Pkts: 1, Bytes: 84
Out: xx.xxx.xx.235/23553 --> xxx.xx.xx.134/787;icmp, If: .local..0, Pkts: 1, Bytes: 84
Total sessions: 8