inotifywait in linux

/usr/bin/inotifywait --timefmt "%c" -mrq -e MODIFY,ATTRIB,CREATE,DELETE --format "%T|%e|%w%f|" $PATH1 $PATH2 $PATH3 | while IFS=\| read TIME EVENT FILE

For the above command, inotifywait will watch the file event (MODIFY,ATTRIB,CREATE,DELETE) for the specified path ($PATH1 - 3).

1. -timefmt "%c"  : what does "%c" mean ?
2. --format "%T|%e|%w%f : what does each % element represent ?

The output of inotifywait will be pipelined to IFS for field separation and then load into TIME EVENT FILE variable, correct ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nearly correct. Or didn't you post the whole thing?

"while" requires a do/done loop, so it should look like this:

... | while IFS=\| read TIME EVENT FILE
      : some code to process the variables

As for the format conversions (derived from the "inotifywait" man page):

%w   name of the watched file/directory on which an event occurred.
%f     When an event occurs within a directory, the name of the file which caused the event. Otherwise empty.
%w%f  thus contains the file's full path when an event occurs on a file in a watched directory.
%e     Event(s) which occurred, comma-separated.
%Xe   Event(s) which occurred, separated by whichever character is in the place of 'X'.
%T     Current Time in the format specified by the --timefmt option

The time formatting is strftime() compliant (as used with the "date" command).

 %c is the locale's appropriate date and time representation (default for "date").

When working with the TIME variable you should quote it ( "$TIME" ) because it will contain spaces.

Note: --timefmt determines what will replace "%T" .

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AXISHKAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.