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 14 of 47    Print  
How would you print just the 25th line in a file (smallest possible script please)?

  
Total Answers and Comments: 22 Last Update: August 06, 2009   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Abhijeet
 
tail -n +25 | head -1 OR
head -n 25 | tail -1

Above answer was rated as good by the following members:
amit.bansal07
  Sorting Options  
  Page 1 of 3   « First    1    2    3    >     Last »  
June 03, 2005 05:03:56   #1  
mallempudi        

RE: How would you print just the 25th line in a file (smallest possible script please)?
how can we connect to database by using solaris?
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
June 06, 2005 07:26:54   #2  
Rishi        

RE: How would you print just the 25th line in a file (smallest possible script please)?
sed -n '25p' filename.txt
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
January 25, 2006 03:55:12   #3  
Vijay Roy        

How To Connect To Data Base in Solaris
echo Enter User Name read nameecho Enter passwd stty -echoread passstty echo sqlplus -s $name@oracle/$pass<
 
Is this answer useful? Yes | No
January 25, 2006 03:56:20   #4  
Vijay Roy        

How To Connect To Data Base in Solaris
echo Enter User Name read nameecho Enter passwd stty -echoread passstty echo sqlplus -s $name@oracle/$pass<
 
Is this answer useful? Yes | No
January 25, 2006 15:12:47   #5  
sumit01_77 Member Since: December 2005   Contribution: 27    

RE: How would you print just the 25th line in a file (...
head -25 filename|tail -1OR
 
Is this answer useful? Yes | No
October 13, 2006 06:06:45   #6  
ruchi sharma        

RE: How would you print just the 25th line in a file (...

head -25 filename|tail -1


 
Is this answer useful? Yes | No
March 07, 2007 00:30:14   #7  
punitha        

RE: How would you print just the 25th line in a file (...

cat -n filename | grep '25'


 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 2Overall Rating: -2    
May 17, 2007 10:59:14   #8  
bhanu_tadiboina        

RE: How would you print just the 25th line in a file (...

head -25 file| tail -1 goes wrong because if some one deletes some lines even then it gives last line as 25th line.
so the right option is

tail +25 file| head -1


 
Is this answer useful? Yes | No
July 11, 2007 10:38:55   #9  
Sri        

RE: How would you print just the 25th line in a file (...
I think both the command results with same answers
 
Is this answer useful? Yes | No
July 13, 2007 02:23:36   #10  
Abhijeet        

RE: How would you print just the 25th line in a file (...
tail -n +25 | head -1 OR
head -n 25 | tail -1

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
  Page 1 of 3   « First    1    2    3    >     Last »  


 
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