I have a script which runs the next command:
find /storage2/hpfiles_staging/ -name \*.gz -mmin +600
And then rsync
's the files to a remote location.
Sometimes the find
command returns no output (as there are no files named *.gz with age of 10 minutes or more in that location).
When it happens, I want to write a message to the log saying there are no files there.
But when I run the find
command, whether it finds files to transfer or not the exit code of the find
command is always "0" (unless there's a syntax error of course) and thus cannot give me indication about files being found in that location or not.
Is there any switch or a trick to get a different exit code than 0 if no files have been found by the find
command?
Thanks in advance