How to find the files that are created in the last hour in unix How to find the files that are created in the last hour in unix unix unix

How to find the files that are created in the last hour in unix


If the dir to search is srch_dir then either

$ find srch_dir -cmin -60 # change time

or

$ find srch_dir -mmin -60 # modification time

or

$ find srch_dir -amin -60 # access time

shows files created, modified or accessed in the last hour.

correction :ctime is for change node time (unsure though, please correct me )


UNIX filesystems (generally) don't store creation times. Instead, there are only access time, (data) modification time, and (inode) change time.

That being said, find has -atime -mtime -ctime predicates:

$ man 1 find...-ctime  n        The primary shall evaluate as true if the time of last change of        file status information subtracted from the initialization time,        divided by 86400 (with any remainder discarded), is n....

Thus find -ctime 0 finds everything for which the inode has changed (e.g. includes file creation, but also counts link count and permissions and filesize change) less than an hour ago.


check out this link and then help yourself out.

the basic code is

#create a temp. fileecho "hi " >  t.tmp# set the file time to 2 hours agotouch -t 200405121120  t.tmp # then check for filesfind /admin//dump -type f  -newer t.tmp -print -exec ls -lt {} \; | pg