I am using inotifywait to monitor a folder by using below way.
inotifywait -m /tmp/test -e CLOSE_WRITE -e MOVED_FROM --format '%T' --timefmt '%s' -q|<action>
In here if any change in /tmp/test i want to do an action.
For example if deleted two files it fires MOVED_FROM event, but i want to call only an action once. If it again modify i wan to fire the same action.
I tried to get the time. And try to get a uniq . But it did not work.
Please let me know any one experience this.
inotifywait ... | uniq
doesn't work because of buffering; you need to line-bufferuniq
to let it print the time of events as long as they're piped to it). – fra-san Jul 30 '20 at 20:12rm foo bar
unlinksfoo
andbar
separately. I don't think there is a way forinotifywait
to know whether you executedrm foo bar
orrm foo
followed byrm bar
. – fra-san Jul 31 '20 at 00:06rm foo bar
, then, after some time,touch baz
") and what you expect the system to do (e.g. only perform "action" once for every command I run (i.e. once forrm foo bar
and once fortouch baz
); or, only perform "action" if the current event is of a different type than the event that triggered the last "action"). – fra-san Jul 31 '20 at 11:51