Unix Shell Script to Find out Files Created within x Hours Without Using mmin / cmin for Solaris

HW=3 # Modify this variable value. In this example it will find out the files created within last 3 hours.
a=$( date +%H )
if [ $a -gt $HW ]; then
    a=$(( $a - $HW ))
else if [ $a -lt $HW ]; then
    a=$(( $a + 24 - $HW ))
else
    a=00
fi
fi
b=`echo $a | sed -e :a -e 's/^.\{1,1\}$/0&/;ta' `
a=$( date +%Y%m%d$b%M )
touch -t $a /tmp/tst
find . -newer /tmp/tst
rm /tmp/tst

No comments:

Post a Comment