File Access Date

by J. Edward Durrett

I came across a directory of backup files the other other day that were no longer needed. Before removing them, I
wanted to see if they had been accessed since they were created. That is simple enough, one would think, just look
at the metadata to see the last time it was accessed. The script handling these backups, however writes them
one day and, after two days, compresses them for long term storage. That way, the most recent backup is already
uncompressed and can be accessed easily. Since the naming convention used for the files also included the date, I
put this script together to check if the files had been accessed since they were compressed:

for n in `ls` ; do
a=`stat -f %Sa -t %d $n`
d=`echo $n|sed 's/xxxx//'|cut -c1-2`
echo "$(($d-$a))" $n

The sed/cut string can be changed to match various file naming conventions as you see fit. With out using the file
name, it is also possible to do something similar using the born on date or modification date, depending on the

Copyright (c) 2019, Jason Edward Durrett - All content on this site, unless otherwise noted, is subject to this license.

Please contact me if any errors, such as erroneous / misleading content or missing / incomplete attribution, are found.