GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  Shell Scripting
Go To First  |  Previous Question  |  Next Question 
 Shell Scripting  |  Question 33 of 47    Print  
How to extract the second row of a text-file?

  
Total Answers and Comments: 6 Last Update: September 24, 2009     Asked by: Ralf Krauseman 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: aamer123
 
 sed -n '2p' datafile

Above answer was rated as good by the following members:
Jenson Kuriakose
June 10, 2007 17:59:28   #1  
gto mitbbs        

RE: How to extract the second row of a text-file?
tail +2 <filename> | head -1
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 20, 2007 10:06:54   #2  
Subramanyam        

RE: How to extract the second row of a text-file?
head -2 filename|tail -1
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
July 09, 2007 10:57:37   #3  
aamer123        

RE: How to extract the second row of a text-file?
sed -n '2p' datafile
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 1Overall Rating: -N/A-    
February 04, 2009 01:02:23   #4  
ajit_saley Member Since: February 2009   Contribution: 5    

RE: How to extract the second row of a text-file?
awk '{print $2}' file_name
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
March 20, 2009 06:56:21   #5  
gcvpgeek Member Since: March 2009   Contribution: 9    

RE: How to extract the second row of a text-file?
sed -n 2 2p file1
 
Is this answer useful? Yes | No
September 24, 2009 05:49:41   #6  
kamalesh_greek Member Since: September 2009   Contribution: 2    

RE: How to extract the second row of a text-file?
head -2 file.txt | tail -1

Regards
kamalesh

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape