Previous: , Up: Time   [Contents][Index]

2.4.2 Comparing Timestamps

Test: -newerXY reference

Succeeds if timestamp ‘X’ of the file being considered is newer than timestamp ‘Y’ of the file reference. The letters ‘X’ and ‘Y’ can be any of the following letters:


Last-access time of reference


Birth time of reference (when this is not known, the test cannot succeed)


Last-change time of reference


Last-modification time of reference


The reference argument is interpreted as a literal time, rather than the name of a file. See Date input formats, for a description of how the timestamp is understood. Tests of the form ‘-newerXt’ are valid but tests of the form ‘-newertY’ are not.

For example the test -newerac /tmp/foo succeeds for all files which have been accessed more recently than /tmp/foo was changed. Here ‘X’ is ‘a’ and ‘Y’ is ‘c’.

Not all files have a known birth time. If ‘Y’ is ‘b’ and the birth time of reference is not available, find exits with an explanatory error message. If ‘X’ is ‘b’ and we do not know the birth time the file currently being considered, the test simply fails (that is, it behaves like -false does).

Some operating systems (for example, most implementations of Unix) do not support file birth times. Some others, for example NetBSD-3.1, do. Even on operating systems which support file birth times, the information may not be available for specific files. For example, under NetBSD, file birth times are supported on UFS2 file systems, but not UFS1 file systems.

There are two ways to list files in /usr modified after February 1 of the current year. One uses ‘-newermt’:

find /usr -newermt "Feb 1"

The other way of doing this works on the versions of find before 4.3.3:

touch -t 02010000 /tmp/stamp$$
find /usr -newer /tmp/stamp$$
rm -f /tmp/stamp$$
Test: -anewer reference
Test: -cnewer reference
Test: -newer reference

True if the time of the last access (or status change or data modification) of the current file is more recent than that of the last data modification of the reference file. As such, ‘-anewer’ is equivalent to ‘-neweram’, ‘-cnewer’ to ‘-newercm’, and ‘-newer’ to ‘-newermm’.

If reference is a symbolic link and the ‘-H’ option or the ‘-L’ option is in effect, then the time of the last data modification of the file it points to is always used.

These tests are affected by ‘-follow’ only if ‘-follow’ comes before them on the command line. See Symbolic Links, for more information on ‘-follow’.

As an example, to list any files modified since /bin/sh was last modified:

find . -newer /bin/sh
Test: -used n

True if the file was last accessed n days after its status was last changed. Useful for finding files that are not being used, and could perhaps be archived or removed to save disk space.

Previous: , Up: Time   [Contents][Index]