I want to understand the following command in Linux:
# tail -n+454 /path/to/a/file | head -n 6
I expect that tail -n+454 /path/to/a/file prints the lines, starting at line 454 and the following 5 lines.
The | sends that output to the head as an input. Then only the first 10 lines are taken.
Finally, -n 6 defines that only the first 6 lines are printed to the screen.
Did I translate the command correctly?
Now I have the following problem: Let's assume I have a file and the following line in it:
# Step #6: Configure output plugins
I want to print the 5 lines immediately before that line (including that line).
First I checked, what line number my line in question has:
nl /path/to/a/file | grep output
![enter image description here](https://lh6.googleusercontent.com/Fvd7Ort8jqHyxKsdsycbT8IgoeyiwxX4ZUxtQjwRROV2JcFC7epFK-Br9TAz9uHQOnP53TT9gpzkSWXeYmiCr5B3qsaWAIhqUyIE2jVw2CPfTdHKnL9EHAWsgmbFhTTB2l21JckM)
The line number is 459.
I want the 5 lines preceding line 459 as well as line 459 itself (that is, lines 454 to 459).
The command tail -n+454 /path/to/a/file | head -n 6 gives me the following output:
![enter image description here](https://lh4.googleusercontent.com/7c5c0GPl0KmiNlQHbLw-tTz5PzdOA6_0AndxAtVRpv3AI8MLSXtm7j1Yl5g0sAG1Zsgqcsgv8_FvQbrG-uyyGI98ze-OpcsBVkGM6wp9NiDlZEJIJw7vrbml-v9W2RCqQanqJf5d)
This is line 380 to 384:
![enter image description here](https://lh3.googleusercontent.com/kE0aWtYmBBswasBYia0PUf-jJ584f5yvsQMr0MIrl7vbTpVrOFz403q6uboVRb2wrx4iFuEcabIyVsXdjAdylpb1rPiu_EWIBLdGfqyYIbyiO47IftySay0OHqleUI8tXV8cNR6H)
I expected to get lines 454 to 459. What did I not understand? Is my command not correct?