An ad-free and cookie-free website.
Learn to view text files at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux less command summary with examples (3:48)
Our fifth word, or command to memorize is
less from the category Text.
less allows you to view and search
text files. In our last video we saw how the man command uses a text
viewer, or pager, to view user manual files. Well, that text viewing
||View a summary of less commands and navigation|
||View line numbers|
If it helps, think of commands as mini programs and most have this
structure. First, type the
command, second the
-option(s) and third the
less command has over
30 options and its argument is typically the file you
intend to read. Many of
the options refer to scrolling and searching for patterns in text.
For now, we only have time to focus on two simple options.
--help, which provides
a tidy screen showing scrolling options. Since there are many text
viewers and editors in Linux, I suggest sticking to, and learning,
only one or two.
-N, for viewing line
So why is
less an important command?
Well, in many flavors of Linux, less is the default viewer for man
pages, and viewing text is an essential task in Linux.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows 10.
Here we go, let's start with
--help and then review this later.
Next, let's use less to view a file I created for this exercise, by
less and the
video5.txt. There it is.
q. Let's do something
different here. Type
less -N and the same file name
See how it numbered the lines? This can be helpful, especially when
reviewing code. Hit
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
The footer of
less -h summary
reminds you of the two most important keys, h for help and q for quit.
Okay, thanks for visiting today. I hope this was a fun introduction
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
If you learned something please consider subscribing as a small token of appreciation. Every one helps get the word out about free learning.
mancommand, hit Back.
pwd, click Next.
A newly-updated free resource. Connect and refer a friend today.