This command works similarly tail in which it can be used to view content of files, except you can also scroll up or down of the file, or jump to specific line with some shortcut keys.
General syntax for
-N option allows you to see line numbers in the output of the less command.
Example: Using this option with the ExampleFile.txt.
-p [word] [filename]
This command helps you find a word or phrase in a file.
Example: Searching for the word “example” in the Example.txt
[file1] [file2] [file3]
Use this command to open multiple files by typing the input file names one by one.
Example: Let’s display several files at once named name1.txt, name2.txt, name3.txt.
This option reduces a series of blanks lines and replaces them with a single blank line.
Example: There are a couple of consecutive blank lines in the randomtext.txt file, let’s see how
less handles them with the
By default, when you exit
less, the contents of the file will be removed from the screen. To keep them on the screen, use the
Example: Leaving the contents of the sometext.txt file in the terminal.