Tail Ignore First Line of File

Tail Ignore First Line of File

You might come across cases where you want to get rid of the first line of a file and see the rest of the contents.

I know there are multiple options to achieve this. A classic one being doing the math with the total number of lines using wc and then using tail.

But why should I know the total number of lines each time I have to ignore first line of file?

Tail Ignore First Line of File

Interestingly, tail provides us with an option to achieve this with ease.

The following is the syntax to get this done.

tail -n +2 [FILE_NAME]

So here’s how it will work.

Let’s consider the following file as an example.

[[email protected] ~]# cat my_test_file.txt
a
b
c
d
e
f
g
h

Using the above mentioned command we will ignore the first line of this file using tail

[[email protected] ~]# tail -n +2 my_test_file.txt
b
c
d
e
f
g
h

Tail Ignore First Line of File

No Comments

Post a Comment

Time limit is exhausted. Please reload CAPTCHA.