Linux Commands Training Quick Tips – Using Linux Less & More Commands to Pause Output

0
4

The more and less commands can be used with the | (verical bar or "pipe" symbol) to pause the output of a Linux command.

Example of Using the Linux more Command

The more command can pause the output of a command, but it does not work as well ..

For example, you can not scroll up in the output of a Linux command with the more command – or search for text in the output of a command.

Run the following command to list the contents of the etc directory, which is off of the / (root) directory – and to see the output "scroll off the top of the screen".

$ <b> ls -l / etc </ b>

Now run the following command example to pause the output of the ls command so that it does not "scroll off the top of the screen".

Be sure to type in the | (vertical bar) between / etc and more .

$ <b> ls -l / etc | </ b> <b> more </ b> Linux Commands Training Tips:

The vertical bar "|" symbol is usually below the Backspace key on your keyboard and is referred to as the "pipe" symbol. It is used to "pipe" the output of one command into another command. In this case, you are "piping" the output of the less command to the more command.

Press the Spacebar a few times to scroll down a "screenful".

Press the up arrow key and then the Page Up key and see that you can not scroll up.

Press q to quit out of the Linux more command.

Example of Using the Linux less Command

Now run the less command example below to pause the output of the ls command.

Make sure you type in the | (vertical bar) between / etc and less.

$ <b> ls -l / etc | less </ b>

This shows the first "page" or "screenful" of the file.

Press the Spacebar to see the next "screen" of output.

Now press the down arrow key a few times, then the up arrow, then press the Page Down key and the Page Up key.

Press the End key to go to the end of the output and then Home to go to the top of the output.

Source

Leave a Reply