R. Bosman
R. Bosman

Reputation: 178

Trigger `inotifywait` action when starting waiting for changes?

I have a bunch of scripts that watch some file for changes:

while inotifywait -e close_write ~/somefile.someext;
  do THINGS
  done

How can I execute THINGS not only when a file changes, but also when first starting the script? I can duplicate the command at the front like below, but ideally I would just pass an option to inotifywait that says "Do it now as well as when this file changes" (THINGS can get rather complex and I would rather not copy it and have to change things in two places (DRY))

THINGS;
while inotifywait -e close_write ~/somefile.someext;
  do THINGS
  done 

Upvotes: 1

Views: 90

Answers (0)

Related Questions