To keep track of newly added files in a directory (and it's subdirs) I want to use
ls -d /tmp/* | entr -p notify-send "new file added."
But when I add new files to
/tmp/foo/ nothing happens. What am I doing wrong?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Is there a particular use case for using
entr ? It is generally strongly discouraged to parse
Why *not* parse `ls` (and what do to instead)?
I think in your case you would be better off using
https://www.howtoforge.com/tutorial/trigger-commands-on-file-or-directory-changes-with-incron/ (IN_CREATE would be of particular interest to your situation)
To my knowledge
incrond is not able to watch subdirectories, so if you need to also watch all subdirectories of /tmp, maybe
watcher is more suited to your situation:
Word of caution, without knowing your special use case: /tmp is used by all kinds of processes. It may not be very wise/practical to try and track all of its changes.