Text Manipulation
25
Viewing Files with more and less
Although
cat
is a good utility for displaying files and creating small files, it
certainly has its limitations when displaying large files. When you use
cat
with
snort.conf, the file scrolls through every page until it comes to the end,
which is not very practical if you want to glean any information from it.
For working with larger files, we have two other viewing utilities:
more
and
less
.
Controlling the Display with more
The
more
command displays a page of a file at a time and lets you page down
through it using the
enter
key. Open
snort.conf with the
more
command, as
shown in Listing 2-7.
kali >
more /etc/snort/snort.conf
--
snip
--
# Snort build options:
# Options: --enable-gre --enable-mpls --enable-targetbased
--enable-ppm --enable-perfprofiling enable-zlib --enable-active
-response --enable-normalizer --enable-reload --enable-react
--enable-flexresp3
#
--More--(2%)
Listing 2-7: Using
more
to display terminal output one page at a time
Notice that
more
displays only the first page and then stops, and it tells us
in the lower-left corner how much of the file is shown (2 percent in this case).
To see additional lines or pages, press
enter
. To exit
more
, enter
q
(for
quit).
Displaying and Filtering with less
The
less
command is very similar to
more
, but with additional functionality
—hence, the common Linux aficionado quip, “Less is more.” With
less
, you
can not only scroll through a file at your leisure, but you can also filter it for
terms. As in Listing 2-8, open
snort.conf with
less
.
kali >