#!/bin/sh
# Use '-r' for gnu sed compatibility
# could back from the matching time to handle Linux & NetBSD ls differences

pkg_recent()
{
ls -lrt /usr/pkg/pkgdb/*/+DESC | \
    sed -r -e 's:/[^/]*$::' -e 's:/.*/: :' -e 's/.*[0-9]+ ([A-Z][a-z][a-z])/\1/'

}

if [ -n "$1" ]; then
    pkg_recent | tail -$1
else
    pkg_recent
fi
