To keep only the most recent files

Hi all,

I'm running on a Sun Solaris machine. I would only want to keep the last 2 most recent files on 1 of my directory.

Below shows my script, but it is incomplete. For the ?? part I do not know how to continue. please help:confused:

DIR=/tmp/abc
OUTPUT=/tmp/output.out
OUTPUT1=/tmp/output1.out

cd $DIR
ls -rt | tail -2 > $OUTPUT
ls > $OUTPUT1
cat $OUTPUT1 | while read archive
do
if [ "$archive" = ?? ]; then
echo "Keeping ..."
else
rm $archive
fi
done

Thank you.

Issue solved.