Lesson 14: Viewing files with less¶
less is a pager program
used to view the contents of a text file. You will not automatically
return to the terminal prompt after the file contents have been
displayed. Pages can be scrolled forward by pressing space and
backward by pressing b. To exit less, press q (for quit).
The less program also does many other useful things (including text
searching using the /character).
Note
Other commands can be found by pressing h key.
Let's add another line to the same file as the previous step and open
the file with less:
[learner planets]$ echo "Earth is the only planet that has liquid water on its surface." >> earth.txt
[learner planets]$ less earth.txt
Note that we use the append operator, >> and not just >. Remember,
if we only used >, we would end up overwriting the file.