#!/home/cyd7997/bin/ksh93.att ################################################################ #### #### The function "isBetween" will determine if the #### modification date/time of a file is between two #### specified dates. The specified dates are expected to be #### in the following format: YYYY-MM-DD HH:MM:SS #### #### The beginning date boundary and the ending date boundary #### must be passed as the first and second arguments to the #### function. The name of the file being examined must be #### passed as the third argument to the function. #### ################################################################ function isBetween { typeset TZ="GMT" typeset LC_ALL="C" export TZ LC_ALL typeset TARGFILE="${3}" typeset MIN=$( printf '%(%s)T' "${1}" ) # (GMT) typeset MAX=$( printf '%(%s)T' "${2}" ) # (GMT) typeset FTYPE typeset FNAME typeset X1 X2 X3 X4 typeset D1 D2 D3 ls -ld "${TARGFILE}" | IFS=$' \t\n' read -r FTYPE X1 X2 X3 X4 D1 D2 D3 FNAME DATESTAMP=$( printf '%(%s)T' "${D1} ${D2} ${D3}" ) if [[ "${FTYPE}" = l* ]] then FNAME="${FNAME/ -> */}" fi if (( DATESTAMP >= MIN )) && (( DATESTAMP <= MAX )) then print -r -- ${MIN} ${MAX} ${DATESTAMP} "${FNAME}" fi } ################################################################ ls -1 | while read -r -- F do isBetween "2004-11-1 00:00:00" "2004-11-17 12:00:00" "${F}" done