0

How to get information about the stream displayed by "less", especially but not limited to number of lines?

Info: reading this answer list of less functions, I did not find out how to know how many lines there are in some command piped to a less, for example, "apt list --installed | less"

1 Answers1

0

After searching the manual page for less, I found the shortcut similar to vim's:

= Prints some information about the file being viewed, including its name and the line number and byte offset of the bottom line being displayed. If possible, it also prints the length of the file, the number of lines in the file and the percent of the file above the last displayed line.

Also of note are the shell commands:

! shell-command Invokes a shell to run the shell-command given. A percent sign (%) in the command is replaced by the name of the current file. (...) "!" with no shell command simply invokes a shell.

  • For "apt list --installed | less", END followed by "=" gives how many packages are installed by apt. – Luiz Silveira Jun 15 '21 at 06:32
  • You could activate the "show line numbers" (`-N`) option and go to the end of the file (`G`). –  Jun 15 '21 at 15:51