Tuesday, August 12, 2008

Script to identify long ago accessed files

He asked me how can he identify long ago accessed files. I've written the following script.

bash-2.05b$ more laaf.sh
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
FNAME=$1
DAYS=$2
if test $# -lt 2
then
echo 'Usage: laaf.sh <+|-N>, where N - number of days'; exit
fi
find $FNAME -type f -atime $DAYS -exec ls -lt --full-time '{}' \; | awk '{print $6,$5,$9;}'
==
Usage: ./laaf.sh <+|-N> [> file.out]
where - is the path to the target directory
<+|-N> - accessed before|after N days

In the output of this script will be modified date, size and file name with full path by row

No comments: