Operating System - HP-UX
1829002 Members
2747 Online
109986 Solutions
New Discussion

Re: HPUX list files with access time more than 5 min

 
Ricardo_78
Occasional Contributor

HPUX list files with access time more than 5 min

Hi, does anyone know how to find files who have the last access time bigger than 5 min ago, in linux i use:
find ./ -amin +5 -type f -maxdepth 1 -name "*.*"
but in hp-ux the find command doesn't have the -amin option....
3 REPLIES 3
Pete Randall
Outstanding Contributor

Re: HPUX list files with access time more than 5 min

Use the touch command to create a reference file of the appropriate time (man touch). Then use find with the -newer option, referencing the "touched" file (man find). In this case it sounds like you would want to use the "not newer" option: ! -newer.


Pete

Pete
Simon Hargrave
Honored Contributor

Re: HPUX list files with access time more than 5 min

You will need to use the -newer switch along with a temporary file.

eg: -

touch 200517081030 /tmp/fiveminutesago
find . -newer /tmp/fiveminutesago

The fun may be generating the timestamp to use. Capturing "date +%Y%d%m%H%M" will give you "now" time, then you'll need to subtract 5 from it, taking into account the hhmm going below 0000 and having to roll back the day/month/year etc as appropriate. Shouldn't be too hard to script, but clearly not as elegant as the GNU find method.
A. Clay Stephenson
Acclaimed Contributor

Re: HPUX list files with access time more than 5 min

You first use the touch command with -a option to create a reference file with a given timestamp. Next you use find ./ -newera reffile. Man touch, find for details.

UNIX ain't Linux.
If it ain't broke, I can fix that.