inotifywait doesn't work as expected
<p>I wanted to write a script that triggers some code when a file gets changed (meaning the content changes or the file gets overwritten by file with the same name) in a specific directory (or in a subdirectory). When running my code and changing a file it seems to run it twice everytime since I get the echo output twice. Is there something I am missing?</p>

<pre><code>while true; do
   change=$(inotifywait -e close_write /home/bla)
   change=${change#/home/bla/ * }
   echo "$change"
done
</code></pre>

<p>Also it doesn't do anything when I change something in a subdirectory of the specified directory.</p>

<p>The outpoot looks like this after i change a file in the specified directory:</p>

<pre><code>Setting up watches.
Watches established.
filename
Setting up watches.
Watches established.
filename
Setting up watches.
Watches established.
</code></pre>