Bash command inotifywait file changes command execution

Executing Commands When Files Change with Bash inotifywait

Introducing how to monitor and watch file changes using the Bash command inotifywait in the Linux command line language Bash, and execute arbitrary commands when changes occur.

Shou Arisaka
1 min read
Nov 17, 2025

Introducing how to monitor and watch file changes using the Bash command inotifywait in the Linux command line language Bash, and execute arbitrary commands when changes occur.

In the following example, hoge is output to standard output when “$PWD/_config.yml” is changed. (I tried to do this with jekyll on docker but couldn’t. It’s a so-called known issue.)

while inotifywait -o ~/inotifywait.log --quiet --timefmt "%a, %d %b %Y %T %z" --format "%T  %f%w  %e" "$PWD/_config.yml"; do echo hoge ; done

Reference: linux - How to execute a command whenever a file changes? - Super User

Share this article

Shou Arisaka Nov 17, 2025

🔗 Copy Links