Inspired by this superuser answer I have written the following copy_library.sh script, saved in the same folder as a file called library.bib:
#!/bin/sh
while inotifywait -e close_write library.bib; do
cp -f ./library.bib ../other_place/ ;
echo "Library copied"
done
If I start this script manually with ./copy_library.sh the process exits after the first copy (which works successfully):
londonrob ~/mydir
> ./copy_library.sh
Setting up watches.
Watches established.
library.bib CLOSE_WRITE,CLOSE
Library copied
Setting up watches.
Watches established.
londonrob ~/mydir
>
and no further changes are tracked. I'm sure I'm supposed to do something with this script so it's running continuously "in the background" without me having to start it manually.
But what?