Changes to the 'find' utility in UNICOS 9

by Tom Parker


For POSIX compliance, the find(1) utility calculates time differently beginning with the UNICOS 9.0 release. You should verify scripts that use the find utility; to achieve the desired results, you may have to rewrite some scripts.

The change affects the -atime, -ctime, and -mtime primaries. The meaning of the numeric argument n to these primaries changed in the following two ways:

Therefore, the find utility now calculates starting points in 24-hour increments from the current time (that is, from now, the current second) rather than from the 24-hour block that started at last midnight. A starting point equals the current time minus 86,400 seconds (the number of seconds in 24 hours) times n. The period defined by n is as follows:

The effects of the first change are illustrated in the following example:

     find . -mtime +0

In UNICOS 8.0 and earlier releases, this command finds any files in the current directory and its subdirectories that are older than last midnight. Some administrators use this as part of a command or script to remove day-old files from /tmp. Conversely, beginning with UNICOS 9.0, this command finds all files older than now (that is, it finds anything older than 24n hours, and because n is 0, it finds all files older than now).

In UNICOS 9.0, to find all files that are older than 24 hours, use the following command:

   find . -mtime +1

The effects of the second change are illustrated in the following command-sequence example:

   find . -mtime +1 -print
   find . -mtime  1 -print
   find . -mtime -1 -print

In UNICOS 8.0 and earlier releases, these three commands produce mutually exclusive listings, which together include any and all files. Beginning with UNICOS 9.0, the second command produces a listing that is almost entirely included in the listing produced by the third command.

In summary, to avoid unexpected results when using the POSIX-compliant find utility, you should verify any scripts that use the find utility with the -atime, -ctime, and -mtime primaries, and you should be aware of these changes in behavior when you invoke the find utility at the command line with these primaries.

Note also, that -print now seems to be the default.


Back to main article