Linux Inotify Expert needed for script

Job ID: 30863257

Budget: $30 – $250 USD

Using Inotify as shown here https://man7.org/linux/man-pages/man7/inotify.7.html

=== Files Needed When Finished ===
(If have attached zip folder which you can use to test)
* a zip file with contains a parent directory and 2 child directories.
* You should place at least 2 files within each of the 2 directories (any kind of file)
* Each directory AND each file should have a space in its name
* The Inotify bash script that will succeed

=== What Bash Script Must Do: ===
Watch a directory which is 3 levels deep or more
When any file has been changed echo the following information:
** The path to the file
** The filename
** The action (MOVED_FROM, MOVED_TO etc...)
** The date time formated as YYYY-MM-DD military time

I have had an impossible time with spaces. They are lumping together values in one variable. I need them separated as shown above.

Below is a FAILED test script. It notifies but does not product the data needed.
Please use this as your base script to correct.

#!/bin/bash
# note spaces in parent directory
# will also have spaces in some of the 3 sub directories
monitor_dir="some dir"

# quote around $monitor_dir insures spaces will be respected
inotifywait -mr -e modify,delete,delete_self,move,create "$monitor_dir" |
# while read path action file;
while read path action file;
do
echo "======================="
echo "filepath [$filepath]"
echo "action [$action]"
echo "filename [$filename]"
echo "action [$action]"
echo "======================="
done
Related categories: Python Linux Apache Shell Script Ubuntu