Need help in identifying a shellscript command to remove all files on a server directory, starting with a certain prefix and also older than 3 days.
That means files created with that prefix, today or yesterday, shouldn't be removed.
The timestamp on a file is the number of seconds since Jan 1 1970. It gets turned into human readable dates using rules in your locale. So, simply subtracting three days from right now may not be what you want - calendar days, not 86400 seconds * 3. One day is 86400 seconds.
Try this: where I am it is Mar 30, 2016
so second "0" of Mar 29 is the cutoff
cd /path/to/files
touch -t 201603290000 dummy
Two options:
just the current directory
for f in prefix*
do
if [ "$f" -ot dummy ] ; then
rm $f
fi
done
whole directory tree starting from current directory