So I want to display 5 lines immediately before a line that says
# Step #6: Configure output plugins in the snort.conf file.
so I use the following to get the line number:
nl /etc/snort/snort.conf | grep output
and the line number is 445
the book then advises to use the following:
tail -n+445 /etc/snort/snort.conf | head -n 6
but this doesn’t work and does not display the 5 line before line 445
tail -n +445 outputs lines starting from 445.
head -n 6 shows the first 6 lines of output.
Together, they show lines 445-451.
If you instead want to show 439-445, you have to adjust accordingly:
tail -n +439 /etc/snort/snort.conf | head -n 6
Answered By – that other guy