Hi I want a list of files modified within 60 minutes.
bash-3.2$ find . -mmin 60 -type f
find: bad option -mmin
find: [-H | -L] path-list predicate-list
bash-3.2$ /usr/xpg4/bin/find . -mmin 60 -type f
/usr/xpg4/bin/find: bad option -mmin
/usr/xpg4/bin/find: [-H | -L] path-list predicate-list
bash-3.2$
utibbwdev1#uname -a
SunOS utibbwdev1 5.10 Generic_150400-13 sun4v sparc SUNW,T5240
I am getting the above error. My OS is sun version 5.10.
Find command can do that.
You can further filter it with
-type f
As you are on SunOS, probably you are not using GNU find, so
-mmin
option is not allowed. Tryto get files/dirs of modification time under (that's the meaning of the minus sign in front of the number) 1 hour from now. GNU finds makes it possible to ask for times in minutes as an extension to normal find.
Also, the man page is very useful, but perhaps, if you have the GNU findutils package installed on your system, you have to do some
PATH
adjustements before to get the correct find program called. Just look as GNU utils normally get installed under /opt/gnu directory and you'll need to put that directory in the PATH before the normal bin dirs. A good way to check this is to dothat will tell you which find it is using and where in the filesystem it is located. A common mistake is to put man pages first in the MANPATH environment variable, but last in the PATH variable, so you get the manpage from GNU findutils package but execute the standard system command. find in SunOS comes from Berkeley Unix and is not related to GNU.
For a POSIX compatible method you can make a temporary file with
touch
, using the time fromdate
, after subtracting one hour withawk
, and usefind
's-newer
operand to compare files with the temporary file.To get a temporary file name you can use a utility such as
mktemp
, you can specify a file, or you can append random numbers to a file name.Quite a few versions of
find
have the-mmin
extension, or something like it.Some versions of
date
have a variable output.And some versions of
touch
have adjustment flags.You can do that using this command.
where,
.
is the search path-mtime
time parameter-1
list files modified in last 1 hoursalso
-amin
time parameter (minute wise)-60
list files modified in last 1 hoursHere is an output from my system: