
The -ctime option can be used to return files and directories that were changed x or more days ago. For example, to return files and directories that were changed 14 or more days ago below the /tmp directory.
find /tmp -ctime +14
Or to return files and directories that were changed in the last x days. For example, to return files and directories that were changed in the last 14 days below the /tmp directory.
find /tmp -ctime -14
For example, to return files and directories that were not changed 14 or more days ago below the /tmp directory.
find /tmp ! -ctime +14
Note - Using the chmod, chown, or chgrp commands would update the last changed datetime of the file.
- The -mtime option can be used to return files and directories that were modified x or more days ago.
- The -atime option can be used to return files and directories that were accessed x or more days ago.
To include the date and time the file was last changed in the output.
- %z = time last changed
- %n = file name
find /tmp -exec stat --format "%z %n" "{}" \;
This will return something like this.
2020-07-06 05:50:18.594805437 -0500 /tmp/foo.txt
2020-07-06 02:10:38.898884577 -0500 /tmp/bar.txt
The stat command can be used to display the time a file was last accessed (atime), last modified (mtime) and last changed (ctime).
~]# stat /tmp/foo.txt
File: ‘/tmp/foo.txt’
Size: 7940168 Blocks: 15520 IO Block: 4096 regular file
Device: fd04h/64772d Inode: 105729 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 409/ john.doe) Gid: ( 2001/admins)
Context: system_u:object_r:usr_t:s0
Access: 2020-03-31 22:44:47.895474745 -0500
Modify: 2020-03-31 22:43:17.434452999 -0500
Change: 2020-03-31 22:43:17.434452999 -0500
Birth: -
Did you find this article helpful?
If so, consider buying me a coffee over at