Using a shell script, can I watch a folder and block program execution until a file in a certain folder changes?
There is inotifywait which seems to do the job, The Wiki
After some suggestions to check out inotifywait I ended up with a solution that works for me as desired.
inotifywait --event modify,create ./targetfolder/; echo "new change, that I am interested in, occurred in targetfolder";It turned out I was interested in both file modification and file creation events.
As another commenter said, you want inotifywait:
The simplest solution is entr, I use it a lot for development - https://www.linuxbash.sh/post/entr-rerun-commands-when-files-change
What is the end goal?
a hobby project: generate a rss feed based on recent file changes in a directory. But I thought this can also have many applications …
- auto formatting code files on change
- automatic backups of a certain folder: run rsync on change in folder.
Are you familiar with CI/CD pipelines? You could use Git along with a service like Woodpecker CI or Gitlab Runners.
Block execution not entirely. You could chmod it as non-x and use inotifywatch to flip it back.
Edit: I misunderstood you, use inotifywait like the other person suggested.
testalso has the-Noption.-N FILE FILE exists and has been modified since it was last read[ -N $file ] && echo "$file has been modified", no?




