I’m writing a bash script, and I’d like to monitor file changes into a directory (adding, deleting and renaming) and performing different action accordingly.
Is there a way to do that directly from my script (aside from periodically ls the directory and make diffs)?
You can use the
inotifywaitcommand (assuming your distribution supports inotify, which most do):