Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-09-2005, 08:41 AM   #1
LQ Newbie
Registered: Oct 2004
Distribution: FC2
Posts: 8

Rep: Reputation: 0
Tail Last Modified File in a Directory

How would one tail the last modified log file within a directory with a single command that does not change? 'ls -t1 | head -1 | tail -f' just gives me an error.

There are new log files being created for each job I have running. It would be nice to have a single command to tail the last log file without typing the tedious name every time.

Old 08-09-2005, 10:23 AM   #2
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55

tail -f $(ls -t1 | head -n 1)

Old 08-09-2005, 10:33 AM   #3
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,307

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i didn't test it out but i think you meant 'back-tick' instead of 'single-quote':

`ls -t1 | head -1 | tail -f`

Old 08-12-2005, 08:42 AM   #4
LQ Newbie
Registered: Oct 2004
Distribution: FC2
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks! Y'all just made my life much easier.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
triggering bash script if directory modified cbb Linux - Software 1 10-23-2004 07:52 AM
monitoring directory to get the modified file names appas Programming 1 09-06-2004 04:56 AM
Get directory stats when a file has been modified? marri Programming 2 05-13-2004 08:44 PM
vi won't save modified file. mimsmall Linux - General 1 03-26-2004 10:04 PM
Can an iso image file be modified? Berhanie Linux - General 3 02-01-2004 09:40 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration