Find command shows the files are present but not found inside the directory

I tried search a files using following find command

find . -type f -mtime +18 -name '*[-.]20[0-9][0-9\-]*' -exec basename {} \;

I can see the files output like .

handh2.access.20210429.bz2

handh2.access.20210428.bz2

handh2.access.20210502.bz2

handh2.access.20210430.bz2

But files are not in the directory

root@web38 135 0 # stat handh2.access.20210429.bz2

stat: cannot stat 'handh2.access.20210429.bz2': No such file or directory

root@web38 136 1 # ls | grep "handh2.access.20210429.bz2"

root@web38 137 1 # 

Any help would be great, thanks.


As several people commented, your find command used the basename utility to explicitly strip off the directory components of the matching files. As a result, you don't know which (sub)directory those files actually reside in.

You can find the full path to the files by changing your find call so that it prints the full paths:

find . -type f -mtime +18 -name '*[-.]20[0-9][0-9\-]*' -ls

or you can find each one individually:

find . -type f -mtime +18 -name handh2.access.20210429.bz2