Linux find files where mtime and ctime are not equal

1.4k views Asked by At

Can I do a find and list files where ctime and mtime are not equal?

find . -type f -name '*.php' -ctime -5 MISSING_PART

MISSING_PART: something like -mtime != -ctime

1

There are 1 answers

1
Pratap On

This can be obtained using stat command. The stat command is used to display file or file system status. The -c option is used to specify the format of the output of this command. The %n format is used to specify the file name. The %Y is used to specify the time of last modification since epoch and %Z specifies the time of last change since epoch.

The command find . -exec stat -c %n#%Y#%Z {} \; | awk -F# '{if ($2 != $3) print $1}' can be used to extract files whose change time and modification time are not equal.

The -ctime n and -mtime n options for find refer to last changed or modified time since n hours ago. This concept of range of time is not captured in this command.