Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 11-17-2006, 06:43 AM   #1
Registered: Oct 2003
Posts: 354

Rep: Reputation: 30
how to program in shell to get a part of a file by line number

Hello everyone,

I am wondering how to program in shell to get a part of a file by indicated (input) line number, for example, get from line 100 to line 200 in a specific file.

What command(s) should I use?

thanks in advance,
Old 11-17-2006, 06:58 AM   #2
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
sed -n '100,200p' inputfile
Old 11-19-2006, 02:41 AM   #3
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Originally Posted by matthewg42
sed -n '100,200p' inputfile

Thank you matthewg42! It works!



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 06:07 PM
Shell Scripting: How to pick lines out of files by line number. Louie55 Programming 3 03-22-2005 06:18 PM
number of command line arguments to shell u4u Linux - General 1 03-04-2005 06:09 PM
Print line number X of a file (in shell) rheza Programming 4 01-04-2005 05:55 PM
Extracting the line number in Unix Shell? Aziz Programming 2 12-01-2004 11:03 AM

All times are GMT -5. The time now is 11:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration