Alright, here's the deal:
I'm writing a bash script that will monitor files being pushed to an FTP server using inotifywait. The idea is to ensure that new files are being pushed continuously (e.g. every 1-2 minutes). My idea is that I can do this by formatting the output of inotifywait to print the seconds since 1970 (to avoid parsing timestamps) and then just comparing that value with the previous file that was added. So far, I have to following command within a while loop:
inotifywait -r -q -e create --format '%T' --timefmt '%s' /home/pete/FTP;
This is working as expected and outputting a large int representing the seconds since 1970.
I want to store this value in a variable to be compared to the next file that is added. The problem is that, since the watch is recursive and monitoring multiple directories within /FTP, I don't know how to store a separate value for each sub-directory.
Essentially, I need a way to store a previousTime value for each sub-directory of /FTP. For example, if FTP contains directories 1, 2, and 3, each with files being added to them continuously, I will need to store the variables previousTime1, previousTime2, and previousTime3. However, these can't really be hard-coded in because the number of directories within /FTP needs to be able to change.
Is there a way for me to keep track of what directory the create event has occurred in (in addition to the timestamp)? Or some better way to do this?
Any suggestions would be great because I'm pretty stumped at this point. Thanks in advance!