When this command is issued from a directory other than where the file is located it works fine:
find /db2/D01/log_archive/ -name "S0002166.LOG" -type f
/db2/D01/log_archive/db2d01/D01/NODE0000/C0000000/S0002166.LOG
When I change -name to -newer, it doesn't work. Find only searches the current directory, not the path specified:
find /db2/D01/log_archive/ -newer "S0002166.LOG" -type f
find: S0002166.LOG: No such file or directory
There are files in the path newer than the one specified. The correct results are returned only if I execute the command in the same directory as the file, so it appears that with -newer, the find path isn't being searched.
What am I doing wrong?
Not really: It searches in the given path but the file given as parameter if no path is given is understood as being in current path, since it cannot find the "newer" file it complains:
The path is given in the find command: /db2/D01/log_archive. You do not specify the path with either -name or -newer, just the filename. Can you give me an example of how you would use the -newer option when the current path is not the path specified in the find command? Thanks for your help.
#Either cd first
cd /db2/D01/log_archive
find . -newer "S0002166.LOG" -type f
#Or specify the full path
find /db2/D01/log_archive/ -newer "/db2/D01/log_archive/S0002166.LOG" -type f