1

Currently I am monitoring the files by using above code, it works as expected. Basically I am monitoring the opened text files and executing commands.

inotifywait -m -q /home/testDir -e open |
    while read path action file; do

        if [[ "$file" =~ .*txt$ ]]; then
      #  execute command
        fi
    done

I wonder, how can I monitor the sequences of the inotifywait events and execute command.

For example, how can I execute a command or echo something when there is a open,access,close_nowrite event in the directory?

/home/TestDir OPEN test.txt
/home/TestDir ACCESS test.txt
/home/TestDIr CLOSE_NOWRITE,CLOSE test.txt
kkk001
  • 31
  • 2
  • Events are reported as they happen, but there is no logic in inotify to detect a sequence of events. You could write something to read the output and do that detection however. – Nic3500 Jan 31 '21 at 22:02

0 Answers0