Search code examples
unixfindshksh

how find newer works in unix


I have this set of similar lines which runs in my server.

PATH = "/home/dept/files/"

for i in '**find . -newer $PATH$(ls $PATH)**'

do
.. some set of codes.. done

I am not getting how the find newer command works here. I saw that Find newer will return the files which are created after the specific time stamp. But I don't see any specific time stamp thats specified after the keyword newer in the find command. Please help me out how find -newer command works here.


Solution

  • The find -newer command will return files which are created after the specific time stamp. The time stamp here is the time stamp of the file defined by $PATH$(ls $PATH).

    If you wish to use this command to look for files modified in for example the last hour you can use the touch command to create a file with a timestamp that is one hour before now. So if it is 2pm now you would use the following command to create a file in the /tmp directory with a timestamp of 1pm: $ touch -mt 09301300 /tmp/file

    Then you would use the find -newer command to find all files that have been modified in the last hour: $ find / -newer /tmp/file -print