findkshhp-ux

how to get number of files older than 1 hour on ksh HP-UX


I need to list set of files created older than 1 hour in certain folder of HP-UX. Following is the command i tried.

find . -type f -mmin +60 | wc -l

But it return following error for ksh

find: bad option -mmin

What is the alternative option to get number of files older than 1 hour?

Even i tried following command. Still another error. But it also work on bash

find . -type f -mtime  +0.04 | wc -l

find: Error in processing the argument 0.04


Solution

  • find in HP-UX has no options for minutes, mtime takes days as argument. You can create a testfile, "touch" it with the desired time and then compare with ! -newer[m]. For instance:

    # onehourago=`date  +"%m %d %H %M" | awk '{ onehourago=$3 - 1 ; if (onehourago<0) { onehourago=59 } printf("%.2d%.2d%.2d%.2d\n",$1,$2,onehourago,$4) }'`
    
    # touch -t "$onehourago" testfile
    
    # find . -type f ! -newer testfile | wc -l