Tail-alike display of new files in directory

The system I work on, produces several kinds of status-files in a single directory. I would like to be able to see the files as they are added to this directory.

I was wondering if it would be possible to get a "tail -f" alike view of the ls-command, in such a way that a newly added file is automagically added at the bottom.

The way we do it now, is with the command below, which we need to execute manually (which imho is not handy):

ls -l -rt|tail -20 (to view 20 last files)

And we do more "in depth" searches inside these files with:

ls -l -rt tail `grep -l searchstring *`

But it would be wonderful to just see the list "grow" since this way, it is much easier to recognize errormessages since these errormessages are fixed size, 645 bytes and easy to spot.

We use SunOS 5.7 with Bash 2.01.

Linux provides a utility called "watch" which you could use to do this. Something like:

watch "ls -lrt | tail -5"

would give you a constantly updated list of the 5 most recently updated files. Unfortunately, I dont think this utility is included with Solaris. It is part of the procps package on Linux. You could try downloading it (http://procps.sourceforge.net/\) and compiling for your architecture.

I do remember watch now! Have not used it in quite some time. I run mostly FreeBSD, OpenBSD and Solaris nowadays and didn't even miss it (until now!)...

I just checked, you're right, it's not included. :frowning:

Even though I am root on this machine, I am not allowed to install any software on it. This is a mission critical system (almost the entire carbranche in The Netherlands would collapse if anything happened to it!).
Getting permission to install additional software on it would require a lot of people to agree with it and I don't think that will happen in the near future.

Thanks for the reply!

A simple shell script alternative would be something like:

#!/bin/sh
while (true)
do
     ls -lrt | tail -5
     sleep 5
     clear
done

Unfortunately the output can getting annoying as it clears the screen every time. "watch" does not suffer the same problem.

This works great!
Thanks a lot!