I'd like to find the MAIN.TXT file in a directory folder. If it is older than 24hours then output YES to the MAIN.txt file. If it hasn't been modified in 24hours then leave the file alone.
I got as far as this:
find /directory -type f -mtime +1 -exec echo 'YES' > /directory/MAIN.txt \;
The MAIN.TXT file is older than 24 hours, so it works. This updates MAIN.TXT mod time to the current time and my MAIN.txt file has YES in it.
If MAIN.TXT is newer than 24hours old, it still modifies the MAIN.TXT with blank txt and changed the modification time.
I know I need a conditional, but I can't seem to get where it goes. Additionally, my mentor mentioned {} for my ECHO parameter but if I do that, then I get the filename with AVAILABLE appended.
YES
to the found file or to another separate file. Could you please clarify that?MAIN.TXT
. Could you please clarify that too?