I have this script :
#!/bin/bash
DIR_TMP=$HOME/.tmp
BIB=$HOME/biblio.bib
inotifywait -m $DIR_TMP -e create -e moved_to |
while read path action file; do
echo $path$file
echo $path$file >> $BIB
cat $path$file >> $BIB
rm $path$file
done
I the while, everything is working fine… but the cat, which doesn't do anything. Why and how to solve this?
The create and the moved_to events return true when a file is created, but it means neither the writing of the file is over nor there is (already) content in the file. In my case, it resulted in the cat being executed before the file was written. So I changed the create and moved_to events to a close_write event. And now everything's fine.