LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-24-2006, 06:39 AM   #1
mahabooba
Member
 
Registered: Dec 2005
Posts: 43

Rep: Reputation: 15
find a Nth line in text file


Hi All,
How I can print "N" th line in normal text file?

Thanks and Regards,
Mahaboob
 
Old 07-24-2006, 06:51 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

There are probably more ways, this came to mind first:

sed -n '10p' infile

This prints line number 10.

Ranges are also possible:

sed -n '3,5p' infile, prints lines 3, 4 and 5.

Hope this helps.
 
Old 07-24-2006, 11:56 PM   #3
mahabooba
Member
 
Registered: Dec 2005
Posts: 43

Original Poster
Rep: Reputation: 15
Thank you.


Regards,
MahaboobAli.Shaik
 
  


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 08:22 AM
Python: find defined text string in a file, and replace the whole line Dark Carnival Programming 6 05-22-2007 06:02 AM
how to change some text of a certain line of a text file with bash and *nix scripting alred Programming 6 07-10-2006 11:55 AM
command line edit -- global find/replace on text file w/o going into vi car182 Linux - Newbie 4 05-25-2006 05:42 PM
SED - display text on specific line of text file 3saul Linux - Software 3 12-29-2005 04:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:59 AM.

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