Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding newest file and tail -f

Status
Not open for further replies.

jehixson

Programmer
Oct 15, 2003
12
0
0
US
Hello again,

I am trying to find a way to find a file by name and date/time created and then tail -f the file. Is there an easy way to do this?

Basically I have 20 files named ***.001 - ***.020. These are files that are continuously writing logs. I need to be able to find the newest file (ls -ltr) aand tail -f the file to see the file in real time.

Any Help would be appreciated.
 
tail -f `ls -tr files | tail -1`

don't forget, RTFMP :) guggach
 
Something like this ?
tail -f `ls -t *.0[012][0-9] | head -1`

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
This is what I get when I run either of the two commands suggested.

> tail -f 'ls -t actv.0* | head -1'
UX:tail: ERROR: Cannot open ls -t actv.0* | head -1: No such file or directory
 
It looks like you're using regular apostrophes (') rather than backticks (`) in your command. Backticks are usually found above the tab key on a regular keyboard. HTH.
 
You may also try something lke this if your shell is korn-like:
tail -f $(ls -t actv.0* | head -1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you all for the help. My problem was that I was using the regular ' and not the `. It is now working. Thanks again for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top