0

To keep track of newly added files in a directory (and it's subdirs) I want to use entr

ls -d /tmp/*  | entr -p notify-send "new file added."

But when I add new files to /tmp/ or /tmp/foo/ nothing happens. What am I doing wrong?

| improve this question | | | | |
0

Is there a particular use case for using entr ? It is generally strongly discouraged to parse ls:
Why *not* parse `ls` (and what do to instead)?

I think in your case you would be better off using incrond:
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:
https://stackoverflow.com/questions/44088179/watch-a-subdirectory-with-incron

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.

| improve this answer | | | | |
  • I want to get notified about incoming email (offlineimap). ls is not a must, but entr seems to be easier to setup on screen notifications – xcy7e May 1 '19 at 17:22
0

Type

ls -d /tmp/* | entr -p echo "New File"

on one pane.Then on another pane type

echo "hello" > /tmp/test123456.txt

Notice that 'New File' is echoed on the first pane

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.