262 Managing Files and Directories
And speaking of reading files...
There are plenty of ways to read files in Linux. In the previous chapter, for example, we covered
the pagers more and less – they’re called pagers because you can “page” through documents one
screen at a time. We also learned how we can not only view but manipulate files with the cat
command.
But there are even more options when it comes time to take a look at README files, man pages or
documents you’ve created.
You have a number of tools to help you read text files, among them, the text editors pico, emacs,
and vim, the pagers more and less,andtheviewershead, tail, cat,andgrep.
Let’s take a look at some of the features in these tools.
The less Command
In Chapter 16 on page 217, we were introduced to the pager less. Less is the pager that’susedto
display man pages.
Let’sviewthemanpageforless to see less in action.
man less
To move forward a screen, press
Space ; to move back a screen, press B ,andtoquit,press Q .
There are other powerful features to less, as well, including the ability to scroll horizontally and
specify the number of lines to scroll.
The more Command
Odd as it may seem, more offers less than less (actually, less was inspired by more).
Let’s take a look at the man page for more, but this time, we’ll open the page using more – by piping
man’soutputtomore.
man more | more
It may not look too different at first, but there are fewer enhancements to more than to less.Proba-
bly the most striking difference at first is the lack of a way to go backwards in a document – although
moving forward by pressing
Space and quitting by pressing Q are the same.
The head Command
You can use the head command if you just want to look at the beginning of a file. The command is:
Comments to this Manuals