LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-09-2005, 09:41 AM   #1
tyoungblood
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.

Thanks,
Tim
 
Old 08-09-2005, 11:23 AM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Try:

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

Lyle
 
Old 08-09-2005, 11:33 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

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

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

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

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


Reply


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 08:52 AM
monitoring directory to get the modified file names appas Programming 1 09-06-2004 05:56 AM
Get directory stats when a file has been modified? marri Programming 2 05-13-2004 09:44 PM
vi won't save modified file. mimsmall Linux - General 1 03-26-2004 11:04 PM
Can an iso image file be modified? Berhanie Linux - General 3 02-01-2004 10:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:24 AM.

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