Entry
how to find/list files older than n "hours" in ksh, not days
Oct 25th, 2001 08:53
Jay Nayegandhi, J Wang,
If you want to find files older than 'n' hours, create
a temp file with the timestamp of whatever you are looking for.
eg. if it is Oct 25, 2020 hours, create a tmp file with the time
1400 - n. On my system, the syntax for the 'touch' command is:
touch -t 10251200 /tmp/file_time_noon
Then use the find command to search for anything older than this
file:
find <begin search path> ! -newer /tmp/files_time_noon
The '!' inverts the "-newer" option.
You can automate this by using the "date" command to get the
current date and time, then subtracting "n" hours from it and
doing the "touch" and "find".