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
Cutting specific lines from a file pathanjalireddy Shell Programming and Scripting 15 06-04-2009 02:32 AM
how to remove specific lines from a file bluemoon1 Shell Programming and Scripting 17 10-07-2007 11:40 PM
replacing specific lines in a file hcclnoodles Shell Programming and Scripting 6 09-30-2006 12:35 PM
How do you specific lines in a file? hedgehog001 UNIX for Dummies Questions & Answers 2 08-23-2005 01:04 AM
Deleting specific lines in a file ramu_1980 Shell Programming and Scripting 4 02-15-2005 01:41 PM

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

Join Date: Feb 2008
Posts: 20
Displaying specific lines in a file.

I'm trying to figure out how to display a certain line in a text file. I keep getting references to Tail and Head, and I know how these work, but i'm lost on how to find say the third out of the five lines and display only that.

I thought maybe grep could help, but that doesn't seem likely.

Any help is greatly appreciated!
  #2 (permalink)  
Old 02-05-2008
denn denn is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 96
To print the 3rd line of a file:

Code:
sed -n '3 p' < filename
  #3 (permalink)  
Old 02-05-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Cool using heads and tails...

> cat f1
line 1
line 2
line 3
line 4
line 5

> head -3 f1 | tail -1
line 3
>

in essence, finding the first three lines of a file, then selecting the last line of what I just found.
  #4 (permalink)  
Old 02-05-2008
MaestroRage MaestroRage is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 20
both of these were mad helpful! Thank you kindly!

I didn't even consider finding first three lines and then the last of those three lines... ingenious D:!
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 09:17 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