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 ... | uniqdoesn't work because of buffering; you need to line-bufferuniqto let it print the time of events as long as they're piped to it). – fra-san Jul 30 '20 at 20:12rm foo barunlinksfooandbarseparately. I don't think there is a way forinotifywaitto know whether you executedrm foo barorrm foofollowed 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 barand 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