Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display all the lines from the nth line of a file in unix

Tags:

linux

bash

unix

sh

I want to display all the lines starting from the nth line. Say, print the third line of a file and all the following lines until end of file. Is there a command for that?

like image 794
user3905438 Avatar asked Sep 05 '14 05:09

user3905438


People also ask

How do I see the last 10 lines of a file in Unix?

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.

How do I show the number of lines in a file in Unix?

The tool wc is the "word counter" in UNIX and UNIX-like operating systems, but you can also use it to count lines in a file by adding the -l option. wc -l foo will count the number of lines in foo .


1 Answers

you can use tail

excerpt from the manpage:

   -n, --lines=K          output the last K lines, instead of the last 10; or use -n +K to          output lines starting with the Kth 

for example

tail -n +10 file  

outputs the files content starting with the 10th line

like image 142
Nikolaus Gradwohl Avatar answered Sep 22 '22 15:09

Nikolaus Gradwohl