The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
print line whatever line i want in a file... there any way kittusri9 Shell Programming and Scripting 1 05-15-2008 09:37 AM
how to print 35th line from a file ? gridview UNIX for Dummies Questions & Answers 9 05-15-2007 01:31 PM
how to print out line numbers of a text file? forevercalz Shell Programming and Scripting 4 12-12-2005 01:04 AM
Print file line by line handak9 Shell Programming and Scripting 2 10-20-2005 05:44 AM
Print one line of Existing File danhodges99 UNIX for Dummies Questions & Answers 2 02-25-2003 07:56 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-10-2007
Registered User
 

Join Date: Sep 2007
Posts: 1
How to print 3rd to last line of file?

Hi,

I have a ksh script I would like to modify.

What I need it to do is look at an ever changing log file and print the 3rd to last line. Is there a command that will display this? I can not use line numbers because the file is always growing.

Thanks for any help
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-10-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
tail -n 3 logfile | head -n 1
Reply With Quote
  #3 (permalink)  
Old 09-10-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,543
Code:
awk 'NR>2' "file"
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0