I have two sensors that each create an entry in a text file when triggered. Now I need something to monitor these two files (i can also put them in 2 directories each if that helps in any way) and trigger a third script only when changes occur to both of the aforementioned files/directories. I need real-time (or near to it) between events and notification. I have found tools like inotify-wait, fswatch, entr and some others but all of these are triggered at any change.

At the moment I'm trying this but it does not work properly:

```
#!/bin/bash
while inotifywait -e modify /home/user/triggerdir/ ;
do
  if [ "inotifywait -e modify /home/user/triggerdir2/" ];
    then
          echo Alert | mail -n -s "test-notify SCRIPT HUZAAAA" user@gmail.com
  else
    # Don't do anything unless we've found one of those
    :
  fi
done

```

I have looked for similar issues/solutions on the web, the closest would be [this](https://unix.stackexchange.com/questions/631954/inotifywait-with-counter-does-not-work) but it has no working answer.