Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-22-2007, 08:34 AM   #1
Registered: Dec 2006
Posts: 97

Rep: Reputation: 15
Show a certain line in file

Hi everyone,

I have a very big text file with over 100 million rows. I want to look at rows 36,000,000 through 36,000,005 for example, how would I do that using the command line? Thanks.
Old 03-22-2007, 09:01 AM   #2
Senior Member
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,625

Rep: Reputation: 142Reputation: 142
sed -n '36000000,36000005P' <logfile>
Old 03-22-2007, 09:13 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
I am pretty sure that sed will do this. Here is the best sed tutorial I have seen:

A crude method is more +num filename. This starts on line "num", and continues one page at a time until stopped
Old 03-22-2007, 09:54 AM   #4
Registered: Dec 2006
Posts: 97

Original Poster
Rep: Reputation: 15
Thank you!
Old 03-22-2007, 10:47 AM   #5
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
How about tail -n +36000000 <file> | head -n 5 ?

And, if you're going to be doing this frequently, consider making the file a data base table indexed on row number, and printing the lines you need with a SQL query.

Last edited by PTrenholme; 03-22-2007 at 10:51 AM.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 09:22 AM
ps doesn't show the full command line OlRoy *BSD 2 01-29-2007 10:34 PM
php - Read file line by line and change a specific line. anrea Programming 2 01-28-2007 02:43 PM
Shell script - how to show a specific line of a text file davi_cabral Linux - Software 3 09-28-2004 02:39 PM
could u show me the last line of your /etc/inittab file? C++freak Linux - Software 2 07-30-2002 09:27 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:44 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
Open Source Consulting | Domain Registration