Unix shell: how to get the last lines of a file other than the first 20?

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

Is there a way to do this with tail

/ head

or another tool?

+13


source to share


4 answers


Try



tail -n +21 myfile.txt

      

+33


source


Try

sed -i 1,20d filename



if you want to delete the first 20 lines!

+5


source


Awk power can also be used:

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

      

+3


source


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

+3


source







All Articles