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
unix shell tail unix-head


source to share


4 answers


Try



tail -n +21 myfile.txt

      

+33


source to share


Try

sed -i 1,20d filename



if you want to delete the first 20 lines!

+5


source to share


Awk power can also be used:

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

      

+3


source to share


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

+3


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics