The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to use sed modify specific lines Jenny.palmy UNIX for Dummies Questions & Answers 5 05-18-2008 06:17 AM
How to print specific lines with awk Bugenhagen Shell Programming and Scripting 10 08-16-2007 06:41 AM
Printing lines with specific awk NF jehrome_rando Shell Programming and Scripting 1 03-13-2007 04:23 AM
How do you specific lines in a file? hedgehog001 UNIX for Dummies Questions & Answers 2 08-23-2005 12:04 AM
Inserting specific lines in vi giannicello UNIX for Dummies Questions & Answers 2 05-01-2002 08:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-25-2006
dakid dakid is offline
Registered User
  
 

Join Date: May 2006
Posts: 27
viewing specific lines

hi,

is there any command on viewing specific line number of a file?

thanks
  #2 (permalink)  
Old 05-25-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
One possible solution is using sed.

If 10 is the line number.

Code:
sed -n "10q;9p" input.txt
  #3 (permalink)  
Old 05-25-2006
dakid dakid is offline
Registered User
  
 

Join Date: May 2006
Posts: 27
thanks,

what is the relation of the value 10 and 9?
sed -n "10q;9p" input.txt
  #4 (permalink)  
Old 05-25-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
It is related to performance issues.

Say your file contains 1000 lines, and you need to view line 50. If you give sed -n "50p", then sed would read through the entire 1000 lines, which is a waste. In case of sed -n "51q;50p", sed would read 51 lines, and then print the 50th line.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0