How can I have ls follow the content of a directory like tail -f does on a file

1

1

I want to basically continuously update the file list of a directory similar to how tail does with the -f flag on a file.

is there any reasonable way to do this?

loosecannon

Posted 2011-07-22T17:59:33.123

Reputation: 275

Answers

9

Try using the watch command with ls:

$ watch ls -l

watch will repeatedly execute the given command at regular (2 second) intervals, which can be configured through command-line options.

user89061

Posted 2011-07-22T17:59:33.123

Reputation:

4

On Linux, use inotify-tools:

inotifywait -qme create,attrib,move,delete mydir |
while read -r; do
    clear
    ls -l mydir
done

Somewhat different:

inotifywait -qme create,attrib,move,delete --format '%w%f' mydir |
while read -r file; do
    ls -ld "$file"
done

user1686

Posted 2011-07-22T17:59:33.123

Reputation: 283 655