LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 07: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, 08:01 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,646

Rep: Reputation: 146Reputation: 146
sed -n '36000000,36000005P' <logfile>
 
Old 03-22-2007, 08:13 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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, 08:54 AM   #4
shahgols
Member
 
Registered: Dec 2006
Posts: 97

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

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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 09:51 AM.
 
  


Reply



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 08:22 AM
ps doesn't show the full command line OlRoy *BSD 2 01-29-2007 09:34 PM
php - Read file line by line and change a specific line. anrea Programming 2 01-28-2007 01:43 PM
Shell script - how to show a specific line of a text file davi_cabral Linux - Software 3 09-28-2004 01:39 PM
could u show me the last line of your /etc/inittab file? C++freak Linux - Software 2 07-30-2002 08:27 AM

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

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