How to get the last lines of a file except the first 20?

23,592

Solution 1

Try

tail -n +21 myfile.txt

Solution 2

Try

sed -i 1,20d filename

if you want to delete the first 20 lines !

Solution 3

Awk power can be used too:

awk -- 'NR > 20' /etc/passwd

Solution 4

I'm rusty with this but something like: tail -n +20 filename

Share:
23,592
kch
Author by

kch

Updated on August 04, 2020

Comments

  • kch
    kch almost 4 years

    Say I have a file with any number of lines, say, 125. I want to get all the lines except the first n, say, 20. So, I want lines 21–125.

    Is there a way to do this with with tail/head, or some other tool?