Find command returning success even when no files are found
I've tested this on RHEL/OUL V5.7 and V6.2 with the same results. I need to search a directory for any files older than 25 hours and then do things with those files.
First case: there are no files named *.xmlx and find returns a 1 correctly # find /mydir/*.xmlx -mmin +1500 find: /mydir/*.xmlx: No such file or directory # echo $? 1 Second case: there are files named *.xml but none meet the mmin requirement yet find returns a 0 instead of a 1 as I was expecting # find /mydir/*.xml -mmin +1500 # echo $? 0 This is messing up my scripting and I'm not figuring a way out. |
find was returning 1 because you gave it a none existing file/dir
it doesn’t return an error simply because your nothing matches your criteria what is it you want to do with the 'found' files? you could pass to while read, and operate on them dumb example.. Code:
find /mydir/*.xml -mmin +1500 | while read file;do |
From man find:
Quote:
Code:
find /mydir -name \*.xmlx -mmin +1500 Code:
while read file |
All times are GMT -5. The time now is 10:27 PM. |