Print all lines excluding header

tags:389-3
Screen Link:

https://app.dataquest.io/m/389/file-inspection/3/option-arguments
My Code:

tail -n +15 'Arts'

What I expected to happen:
All data lines of Arts to be printed, excluding header.

What actually happened:
No output.

I don’t understand the code for printing all lines except the header, even the explanation does not make sense to me. For example, why does

/home/learn$ tail -n +15 example_data.csv 

only output these two lines:
13,0,C,965,898
14,1,B,297,585

1 Like

Please make sure you format your post details appropriately so that you are distinguishing between code (or terminal commands) lines, outputs of those code lines, and your own statements.

Here is a great helping vid:

2 Likes

Tail being the last 10 rows (by default) makes sense. But why would +15 result in the last two lines being output in the lesson example?

1 Like

By using

 tail -n +15 file.txt

tail displays all the data after skipping 15 lines from starting of the specified file.

so in your case it skipped 15 lines then displayed the rest which was only two :slight_smile:

Hope this solves your problem :slight_smile:


Some Very Helpful Resources:

6 Likes

Thanks for the explanation and the links. So +num means it starts printing from that line(position) number. I’d forgotten that the index started with index 0 after the header, not 1. Thanks again!

1 Like