22
Chapter 2
Numbering the Lines
Sometimes—especially with very long files—we may want the file to display
line numbers. Since
snort.conf has more than 600 lines, line numbers would
be useful here. This makes it easier to reference changes and come back to
the same place within the file.
To display a file with line numbers, we use the
nl
(number lines) com-
mand. Simply enter the command shown in Listing 2-4.
kali >
nl /etc/snort/snort.conf
612 #################################################################
613 #dynamic library rules
614 #include $SO_RULE_PATH/bad-traffic.rules
615 #include $SO_RULE_PATH/chat.rules
--
snip
--
630 #include $SO_RULE_PATH/web-iis.rules
631 #include $SO_RULE_PATH/web-misc.rules
632 #Event thresholding or suppression commands. See threshold.conf
633 include threshold.conf
Listing 2-4: Displaying line numbers in terminal output
Each line now has a number, making referencing much easier. Note that
this command skips the numbering for the blank lines.
Filtering Text with grep
The command
grep
is probably the most widely used text manipulation com-
mand. It lets you filter the content of a file for display. If, for instance, you
want to see all lines that include the word
output in your
snort.conf file, you
could use
cat
and ask it to display only those lines (see Listing 2-5).
kali >