Is there a tail -f equivalent for ls?

Solution 1:

Try watch.

Taken from here:

watch -d ls -l

A friend and I tried this a moment ago, it seems that the highlighting doesn't really work correctly, it will highlight a seemingly random selection. I've tried this in an OS X Terminal ssh'd to a RHEL5 machine and my friend has tried in a Ubuntu GUI terminal.

Unfortunately inotifywait is not present on the RHEL5 machine so I can't give any information on the effectiveness of that command.

Solution 2:

inotifywait from inotify-tools shows a real-time log of file modifications, similar to tail -f.

inotifywait -m -q -e create,delete,move /dir

-r can be added for recursive watches (can be a little slow with many subdirectories), --format to change the output format (e.g. add timestamps or join the path & filename).

Example output:

/home/grawity/code/bin/ CREATE,ISDIR fallback
/home/grawity/code/bin/ CREATE gnome-inhibit-list
/home/grawity/code/bin/ CREATE k5translate
/home/grawity/code/bin/ MOVED_FROM logout
/home/grawity/code/bin/ DELETE pacman-sigstats

(By the way, tail -f also uses inotify to follow file changes.)