"find" and {a,c,m}time

Tim J Ihde tim at attdso.ATT.COM
Thu Oct 13 04:05:18 AEST 1988


In article <170 at libove.UUCP> root at libove.UUCP (Jay M. Libove) writes:
>My manual entry for find(C) (SCO uses bogus manual sections, that should
>be find(1) to the real world I think) says:
>
>find pathname-list expression
>...
>-atime n	True if the file has been accessed in n days.
>-ctime n	True if the file has been changed in n days.
>-mtime n	True if the file has been modified in n days.
>
>Okay, so "find -?time 3 -print" should find all files ?'d within the
>last three days, right?

Close.  If you look at the first paragraph in the description section, you
will see:

	"In the descriptions, the argument n is used as a decimal
	integer where +n means more than n, -n means less than n
	and n means exactly n."

Therefore if you want all files ?'d within the last three days, you
should use "find -?time -3 -print."

It is also sometimes helpful to note exactly what atime, mtime, and ctime
mean.  These times are read using the stat(2) system call and
are as defined on that man page, which shows which system calls change
which time:

atime		creat(2), mknod(2), pipe(2), utime(2), read(2)	

mtime		creat(2), mknod(2), pipe(2), utime(2), write(2)	

ctime		chmod(2), chown(2), creat(2), link(2), mknod(2),
		pipe(2), unlink(2), utime(2), write(2)	

Also, be aware of which of these times ls is giving you.  Normally,
you see mtime; -u will give you atime and -c will give you ctime.

Given that, let me say that I don't really like using the -?time options
for incrementals.  It would be too easy to miss something using units
like "days" (I'm not positive what that means in this context: does -1
mean yesterday or 24 hours ago?)  Rather, I usually do something like

	find . -newer old_flist -print | tee new_flist | cpio . . .

This works pretty well, but be careful of files changed during the
process; they might not get backed up today and skipped tomorrow.  Usually
I do this sort of thing from single user mode.
-- 
Tim J Ihde				UUCP:	    att!attdso!tim
(201) 898-6687				INTERNET:   tim at attdso.att.com
"Blimey - this redistribution of wealth is more complicated than I'd thought!"
		- Dennis Moore and various Presidents



More information about the Comp.unix.questions mailing list