Now, 'find . -new reference_file' will return all files created since
reference_file was created.
--- findutils-4.2.28/find/find.1 2006-04-01 05:55:04 +0800
+++ findutils-4.2.28/find/find.1.new 2006-10-10 14:52:13 +0800
@@ -112,7 +112,7 @@
When the \-H or \-L options are in effect, any symbolic links listed
as the argument of \-newer will be dereferenced, and the timestamp
will be taken from the file to which the symbolic link points. The
-same consideration applies to \-anewer and \-cnewer.
+same consideration applies to \-new, \-anewer and \-cnewer.
The \-follow option has a similar effect to \-L, though it takes
effect at the point where it appears (that is, if \-L is not used but
@@ -152,7 +152,7 @@
been specified, the position of the \-follow option changes the
behaviour of the \-newer predicate; any files listed as the argument
of \-newer will be dereferenced if they are symbolic links. The same
-consideration applies to \-anewer and \-cnewer. Similarly, the \-type
+consideration applies to \-new, \-anewer and \-cnewer. Similarly, the \-type
predicate will always match against the type of the file that a
symbolic link points to rather than the link itself. Using \-follow
causes the \-lname and \-ilname predicates always to return false.
@@ -331,6 +331,10 @@
in order to protect it from expansion by the shell.
+.IP "\-new \fIfile\fR"
+File was modified more recently or same as \fIfile\fR. If \fIfile\fR is a
+symbolic link and the \-H option or the \-L option is in effect, the
+modification time of the file it points to is always used.
.IP "\-newer \fIfile\fR"
File was modified more recently than \fIfile\fR. If \fIfile\fR is a
symbolic link and the \-H option or the \-L option is in effect, the
modification time of the file it points to is always used.
@@ -945,6 +949,9 @@
Supported. Interpretation of the response is not locale-dependent
(see ENVIRONMENT VARIABLES).
+.IP "\-new"
+Supported. See \-newer.
+
.IP "\-newer"
Supported. If the file specified is a symbolic link, it is always
dereferenced. This is a change from previous behaviour, which used to
--- findutils-4.2.28/find/parser.c 2006-08-05 21:16:16 +0800
+++ findutils-4.2.28/find/parser.c.new 2006-10-10 14:47:33 +0800
@@ -118,6 +118,7 @@
static boolean parse_name PARAMS((const struct parser_table*, char
*argv[], int *arg_ptr));
static boolean parse_negate PARAMS((const struct parser_table*, char
*argv[], int *arg_ptr));
static boolean parse_newer PARAMS((const struct parser_table*, char
*argv[], int *arg_ptr));
+static boolean parse_new PARAMS((const struct parser_table*, char
*argv[], int *arg_ptr));
static boolean parse_noleaf PARAMS((const struct parser_table*, char
*argv[], int *arg_ptr));
static boolean parse_nogroup PARAMS((const struct parser_table*, char
*argv[], int *arg_ptr));
static boolean parse_nouser PARAMS((const struct parser_table*, char
*argv[], int *arg_ptr));
@@ -249,6 +250,7 @@
#ifdef UNIMPLEMENTED_UNIX
PARSE(ARG_UNIMPLEMENTED, "ncpio", ncpio), /* Unix */
#endif
+ PARSE_TEST ("new", new),
PARSE_TEST ("newer", newer),
PARSE_OPTION ("noleaf", noleaf), /* GNU */
PARSE_TEST ("nogroup", nogroup),
@@ -796,7 +798,7 @@
tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N\n\
-cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME\n\
-ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex
PATTERN\n\
- -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE"));
+ -links N -lname PATTERN -mmin N -mtime N -name PATTERN -new FILE -newer
FILE"));
puts (_("\
-nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN\n\
-wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n\
@@ -1065,6 +1067,25 @@
}
static boolean
+parse_new (const struct parser_table* entry, char **argv, int *arg_ptr)
+{
+ struct predicate *our_pred;
+ struct stat stat_new;
+
+ (void) argv;
+ (void) arg_ptr;
+
+ if ((argv == NULL) || (argv[*arg_ptr] == NULL))
+ return false;
+ if ((*options.xstat) (argv[*arg_ptr], &stat_new))
+ error (1, errno, "%s", argv[*arg_ptr]);
+ our_pred = insert_primary (entry);
+ our_pred->args.time = stat_new.st_mtime;
+ (*arg_ptr)++;
+ return true;
+}
+
+static boolean
parse_newer (const struct parser_table* entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
--- findutils-4.2.28/find/pred.c 2006-04-01 05:55:04 +0800
+++ findutils-4.2.28/find/pred.c.new 2006-10-10 14:48:48 +0800
@@ -194,6 +194,7 @@
{pred_mtime, "mtime "},
{pred_name, "name "},
{pred_negate, "not "},
+ {pred_new, "new "},
{pred_newer, "newer "},
{pred_nogroup, "nogroup "},
{pred_nouser, "nouser "},
@@ -1109,6 +1110,16 @@
}
boolean
+pred_new (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
+{
+ (void) pathname;
+
+ if (stat_buf->st_mtime >= pred_ptr->args.time)
+ return (true);
+ return (false);
+}
+
+boolean
pred_newer (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
{
(void) pathname;
--- findutils-4.2.28/find/defs.h 2006-06-15 05:42:48 +0800
+++ findutils-4.2.28/find/defs.h.new 2006-10-10 14:49:26 +0800
@@ -459,6 +459,7 @@
boolean pred_mtime PARAMS((char *pathname, struct stat *stat_buf, struct
predicate *pred_ptr));
boolean pred_name PARAMS((char *pathname, struct stat *stat_buf, struct
predicate *pred_ptr));
boolean pred_negate PARAMS((char *pathname, struct stat *stat_buf, struct
predicate *pred_ptr));
+boolean pred_new PARAMS((char *pathname, struct stat *stat_buf, struct
predicate *pred_ptr));
boolean pred_newer PARAMS((char *pathname, struct stat *stat_buf, struct
predicate *pred_ptr));
boolean pred_nogroup PARAMS((char *pathname, struct stat *stat_buf, struct
predicate *pred_ptr));
boolean pred_nouser PARAMS((char *pathname, struct stat *stat_buf, struct
predicate *pred_ptr));
--- findutils-4.2.28/ChangeLog 2006-04-01 05:55:04 +0800
+++ findutils-4.2.28/ChangeLog.new 2006-10-10 15:01:41 +0800
@@ -1,3 +1,9 @@
+2006-10-10 Jeff Chua <address@hidden>
+
+ * find/find.1, find/parser.c, find/pred.c, find/defs.h:
+ Added '-new'. '-newer' only finds newer files. '-new' finds
+ files that were modified more recently or same as the file specified.
+
2005-12-10 Andreas Metzler <address@hidden>
* find/defs.h, find/parser.c: fixed compilation warning caused by
Thanks,
Jeff
[ address@hidden ]