Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 304
kch Avatar asked Nov 24 '08 14:11

kch


People also ask

How can you view the last 15 lines of the file?

head -15 /etc/passwd To look at the last few lines of a file, use the tail command. tail works the same way as head: type tail and the filename to see the last 10 lines of that file, or type tail -number filename to see the last number lines of the file. Try using tail to look at the last five lines of your .

Which command will get you all lines except last two lines of the?

Awk command to print all the lines except the last three lines.

How do I make the first 10 lines of a file read only?

To look at the first few lines of a file, type head filename, where filename is the name of the file you want to look at, and then press <Enter>. By default, head shows you the first 10 lines of a file. You can change this by typing head -number filename, where number is the number of lines you want to see.

What command will show me the last 10 lines of a file by default?

tail [OPTION]... [ Tail is a command which prints the last few number of lines (10 lines by default) of a certain file, then terminates.


1 Answers

Try

tail -n +21 myfile.txt
like image 184
unwind Avatar answered Sep 22 '22 16:09

unwind