mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-06 13:09:50 +00:00
Add the primaries -mmin, -amin, -cmin to find, similar to the GNU find.
This commit is contained in:
parent
6ab2db5e53
commit
3f5223f84a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30395
@ -47,7 +47,9 @@ struct stat;
|
||||
void printlong __P((char *, char *, struct stat *));
|
||||
int queryuser __P((char **));
|
||||
|
||||
PLAN *c_amin __P((char *));
|
||||
PLAN *c_atime __P((char *));
|
||||
PLAN *c_cmin __P((char *));
|
||||
PLAN *c_ctime __P((char *));
|
||||
PLAN *c_delete __P((void));
|
||||
PLAN *c_depth __P((void));
|
||||
@ -74,6 +76,7 @@ PLAN *c_user __P((char *));
|
||||
PLAN *c_xdev __P((void));
|
||||
PLAN *c_openparen __P((void));
|
||||
PLAN *c_closeparen __P((void));
|
||||
PLAN *c_mmin __P((char *));
|
||||
PLAN *c_mtime __P((char *));
|
||||
PLAN *c_not __P((void));
|
||||
PLAN *c_or __P((void));
|
||||
|
@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)find.1 8.7 (Berkeley) 5/9/95
|
||||
.\" $Id: find.1,v 1.10 1997/05/19 18:16:00 jdp Exp $
|
||||
.\" $Id: find.1,v 1.11 1997/08/29 23:09:41 imp Exp $
|
||||
.\"
|
||||
.Dd May 9, 1995
|
||||
.Dt FIND 1
|
||||
@ -131,12 +131,25 @@ than that of the file from which the descent began.
|
||||
.El
|
||||
.Sh PRIMARIES
|
||||
.Bl -tag -width Ds
|
||||
.It Ic -amin Ar n
|
||||
True if the difference between the file last access time and the time
|
||||
.Nm find
|
||||
was started, rounded up to the next full minutes period, is
|
||||
.Ar n
|
||||
minutes periods.
|
||||
.It Ic -atime Ar n
|
||||
True if the difference between the file last access time and the time
|
||||
.Nm find
|
||||
was started, rounded up to the next full 24\-hour period, is
|
||||
.Ar n
|
||||
24\-hour periods.
|
||||
.It Ic -cmin Ar n
|
||||
True if the difference between the time of last change of file status
|
||||
information and the time
|
||||
.Nm find
|
||||
was started, rounded up to the next full minutes period, is
|
||||
.Ar n
|
||||
minutes periods.
|
||||
.It Ic -ctime Ar n
|
||||
True if the difference between the time of last change of file status
|
||||
information and the time
|
||||
@ -214,6 +227,12 @@ will be displayed instead of the size in bytes.
|
||||
If the file is a symbolic link, the pathname of the linked\-to file will be
|
||||
displayed preceded by ``\->''.
|
||||
The format is identical to that produced by ``ls \-dgils''.
|
||||
.It Ic -mmin Ar n
|
||||
True if the difference between the file last modification time and the time
|
||||
.Nm find
|
||||
was started, rounded up to the next full minutes period, is
|
||||
.Ar n
|
||||
minutes periods.
|
||||
.It Ic -mtime Ar n
|
||||
True if the difference between the file last modification time and the time
|
||||
.Nm find
|
||||
|
@ -39,8 +39,10 @@
|
||||
/* node type */
|
||||
enum ntype {
|
||||
N_AND = 1, /* must start > 0 */
|
||||
N_ATIME, N_CLOSEPAREN, N_CTIME, N_DEPTH, N_EXEC, N_EXECDIR, N_EXPR,
|
||||
N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MTIME, N_NAME,
|
||||
N_AMIN, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CTIME, N_DEPTH,
|
||||
N_EXEC, N_EXECDIR, N_EXPR,
|
||||
N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MMIN,
|
||||
N_MTIME, N_NAME,
|
||||
N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH,
|
||||
N_PERM, N_PRINT, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
|
||||
N_PRINT0, N_DELETE
|
||||
|
@ -125,6 +125,38 @@ find_parsenum(plan, option, vp, endch)
|
||||
if ((p)->type == ttype && (p)->flags == F_LESSTHAN) \
|
||||
++((p)->t_data);
|
||||
|
||||
/*
|
||||
* -amin n functions --
|
||||
*
|
||||
* True if the difference between the file access time and the
|
||||
* current time is n min periods.
|
||||
*/
|
||||
int
|
||||
f_amin(plan, entry)
|
||||
PLAN *plan;
|
||||
FTSENT *entry;
|
||||
{
|
||||
extern time_t now;
|
||||
|
||||
COMPARE((now - entry->fts_statp->st_atime +
|
||||
60 - 1) / 60, plan->t_data);
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_amin(arg)
|
||||
char *arg;
|
||||
{
|
||||
PLAN *new;
|
||||
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_AMIN, f_amin);
|
||||
new->t_data = find_parsenum(new, "-amin", arg, NULL);
|
||||
TIME_CORRECT(new, N_AMIN);
|
||||
return (new);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* -atime n functions --
|
||||
*
|
||||
@ -155,6 +187,39 @@ c_atime(arg)
|
||||
TIME_CORRECT(new, N_ATIME);
|
||||
return (new);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* -cmin n functions --
|
||||
*
|
||||
* True if the difference between the last change of file
|
||||
* status information and the current time is n min periods.
|
||||
*/
|
||||
int
|
||||
f_cmin(plan, entry)
|
||||
PLAN *plan;
|
||||
FTSENT *entry;
|
||||
{
|
||||
extern time_t now;
|
||||
|
||||
COMPARE((now - entry->fts_statp->st_ctime +
|
||||
60 - 1) / 60, plan->t_data);
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_cmin(arg)
|
||||
char *arg;
|
||||
{
|
||||
PLAN *new;
|
||||
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_CMIN, f_cmin);
|
||||
new->t_data = find_parsenum(new, "-cmin", arg, NULL);
|
||||
TIME_CORRECT(new, N_CMIN);
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
* -ctime n functions --
|
||||
*
|
||||
@ -186,6 +251,7 @@ c_ctime(arg)
|
||||
return (new);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* -depth functions --
|
||||
*
|
||||
@ -677,6 +743,38 @@ c_mtime(arg)
|
||||
return (new);
|
||||
}
|
||||
|
||||
/*
|
||||
* -mmin n functions --
|
||||
*
|
||||
* True if the difference between the file modification time and the
|
||||
* current time is n min periods.
|
||||
*/
|
||||
int
|
||||
f_mmin(plan, entry)
|
||||
PLAN *plan;
|
||||
FTSENT *entry;
|
||||
{
|
||||
extern time_t now;
|
||||
|
||||
COMPARE((now - entry->fts_statp->st_mtime + 60 - 1) /
|
||||
60, plan->t_data);
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_mmin(arg)
|
||||
char *arg;
|
||||
{
|
||||
PLAN *new;
|
||||
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_MMIN, f_mmin);
|
||||
new->t_data = find_parsenum(new, "-mmin", arg, NULL);
|
||||
TIME_CORRECT(new, N_MMIN);
|
||||
return (new);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* -name functions --
|
||||
*
|
||||
|
@ -58,7 +58,9 @@ static OPTION const options[] = {
|
||||
{ ")", N_CLOSEPAREN, c_closeparen, O_ZERO },
|
||||
{ "-a", N_AND, NULL, O_NONE },
|
||||
{ "-and", N_AND, NULL, O_NONE },
|
||||
{ "-amin", N_AMIN, c_amin, O_ARGV },
|
||||
{ "-atime", N_ATIME, c_atime, O_ARGV },
|
||||
{ "-cmin", N_CMIN, c_cmin, O_ARGV },
|
||||
{ "-ctime", N_CTIME, c_ctime, O_ARGV },
|
||||
{ "-delete", N_DELETE, c_delete, O_ZERO },
|
||||
{ "-depth", N_DEPTH, c_depth, O_ZERO },
|
||||
@ -70,6 +72,7 @@ static OPTION const options[] = {
|
||||
{ "-inum", N_INUM, c_inum, O_ARGV },
|
||||
{ "-links", N_LINKS, c_links, O_ARGV },
|
||||
{ "-ls", N_LS, c_ls, O_ZERO },
|
||||
{ "-mmin", N_MMIN, c_mmin, O_ARGV },
|
||||
{ "-mtime", N_MTIME, c_mtime, O_ARGV },
|
||||
{ "-name", N_NAME, c_name, O_ARGV },
|
||||
{ "-newer", N_NEWER, c_newer, O_ARGV },
|
||||
|
Loading…
Reference in New Issue
Block a user