2019-01-01 17:07:29 +00:00
|
|
|
# inotifywait
|
|
|
|
|
|
|
|
> Waits for changes to one or more files.
|
2021-09-02 19:33:49 +01:00
|
|
|
> More information: <https://manned.org/inotifywait>.
|
2019-01-01 17:07:29 +00:00
|
|
|
|
|
|
|
- Run a command when a file changes:
|
|
|
|
|
|
|
|
`while inotifywait {{path/to/file}}; do {{command}}; done`
|
|
|
|
|
|
|
|
- Be quiet about watching for changes:
|
|
|
|
|
|
|
|
`while inotifywait --quiet {{path/to/file}}; do {{command}}; done`
|
|
|
|
|
|
|
|
- Watch a directory recursively for changes:
|
|
|
|
|
|
|
|
`while inotifywait --recursive {{path/to/directory}}; do {{command}}; done`
|
|
|
|
|
|
|
|
- Exclude files matching a regular expression:
|
|
|
|
|
2021-08-05 13:56:47 +01:00
|
|
|
`while inotifywait --recursive {{path/to/directory}} --exclude '{{regular_expression}}'; do {{command}}; done`
|
2019-01-01 17:07:29 +00:00
|
|
|
|
|
|
|
- Wait at most 30 seconds:
|
|
|
|
|
|
|
|
`while inotifywait --timeout {{30}} {{path/to/file}}; do {{command}}; done`
|
|
|
|
|
|
|
|
- Only watch for file modification events:
|
|
|
|
|
|
|
|
`while inotifywait --event {{modify}} {{path/to/file}}; do {{command}}; done`
|