0

I had inotifywait working well, and suddenly it has stopped working as I expected. I'm not sure what's happening. My script:

#!/bin/bash

while inotifywait -e modify foo.txt; do
        echo we did it
done
echo $?

When I execute it, I get:

Setting up watches.
Watches established.

When I edit foo.txt, I get:

0

And then the script exits.

  • Why is the while loop exiting given that the exit code is 0?

  • Why is it never echoing the content of the while loop?

UPDATE

This version does work. However I still don't get what's wrong with the original (given that, I swear, it was working for some time.)

#!/bin/bash


echo helle

while true; do
        inotifywait -e modify foo.txt
        echo hello
done
user717847
  • 695
  • 1
  • 6
  • 16

0 Answers0