print a certain line counted from the end of an output stream

This is a discussion on print a certain line counted from the end of an output stream within the awk forums in Programming Languages category; Oftentimes I need to print, say, the 4th line from the end of an output stream. I've been using constructs of the sort cat file | tail -4 | head -1 Is there a more elegant tool / approach (sed/awk/head/tail whatever!)? -- Rahul...

Go Back   Application Development Forum > Programming Languages > awk

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-15-2008, 05:15 PM
Rahul
Guest
 
Default print a certain line counted from the end of an output stream

Oftentimes I need to print, say, the 4th line from the end of an output
stream. I've been using constructs of the sort

cat file | tail -4 | head -1

Is there a more elegant tool / approach (sed/awk/head/tail whatever!)?

--
Rahul
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:41 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.