pkgatime
Display the most recent access time of a packages
File contents
#!/bin/bash
LOCAL_DB=/var/lib/pacman/local
usage() {
cat <<EOF
usage: pkgatime [packageprefix]
pkgatime will display the most recent access time of a package (by
searching all access times of the files in a package) or all installed
packages (if "package" is ommited) sorted by access time.
Example Usage 1 -> most recent access times of all packages:
# pkgatime
Example Usage 2 -> most recent access times of apache:
# pkgatime apache
EOF
}
seconds_to_humandate() {
date -d "01/01/1970 $1 seconds UTC"
}
if [ "$1" = "--help" -o "$1" = "-h" ]; then
usage
exit 0
fi
for packagedir in `find $LOCAL_DB -mindepth 1 -maxdepth 1 -type d -name ${1}\*`;do
package=`basename $packagedir`
db_file=$packagedir/files
seconds=`awk '$1 ~ /\/[^\/]+$/ {if (NF==1) print "/"$1}' ${db_file}|xargs stat --format "%X"|sort -n|tail -n 1`
if ${PIPESTATUS[1]} ;then
echo $package $seconds `seconds_to_humandate $seconds`
fi
done|sort -k 2 -n
Click here to get the file
