I'm trying to understand the output of the find command with the
-cnewer test. In doing some limited testing, this is what I get.
First, I created a file:
cd ~/Documents touch file1.txt
Then I waited a few minutes before creating another file:
Then I decided to compare the content timestamp to the metadata timestamp by doing:
ls -lht (for content timestamp) -rw-rw-r-- 1 mason mason 0 Aug 11 01:19 file2.txt -rw-rw-r-- 1 mason mason 0 Aug 11 01:17 file1.txt
ls -lhtc (for metadata timestamp) -rw-rw-r-- 1 mason mason 0 Aug 11 01:19 file2.txt -rw-rw-r-- 1 mason mason 0 Aug 11 01:17 file1.txt
So far no surprises, since I haven't done anything to change the metadata timestamp.
Now if I type:
chmod 664 file1.txt
to change the metadata timestamp, and then look at the output again:
ls -lhtc -rw-rw-r-- 1 mason mason 0 Aug 11 01:23 file1.txt -rw-rw-r-- 1 mason mason 0 Aug 11 01:19 file2.txt
file1.txt appears in first position in the
ls -lhtc output, but still in second position in the
ls -lht output, also as expected.
Finally, if I decide to type:
cd ~/Documents find . -cnewer file1.txt
. ./file2.txt ./file1.txt
Here are the questions I have:
-cnewerlook for? Does it look to see if the metadata timestamp has changed or does it look for whether the content timestamp has changed? Does it do both? I'm pretty sure it does both, but I'd like to be sure.
-cnewerdoes both, why does
file1.txtend up in the output? I can understand why
file2.txtends up in the output, since find will look for a more recent content timestamp than
file1.txt, but I still don't understand why
file1.txtends up in the output. After all, there is no file with a more recent metadata timestamp in the
ls -lhtcoutput than