LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-22-2007, 08:34 AM   #1
shahgols
Member
 
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
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,594

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

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I am pretty sure that sed will do this. Here is the best sed tutorial I have seen:
http://www.grymoire.com/Unix/Sed.html

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
shahgols
Member
 
Registered: Dec 2006
Posts: 97

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

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

<edit>
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.
</edit>

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


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:54 PM.

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