#!/usr/bin/env bash files_to_remove=$(find . -maxdepth 1 -type f|cut -c3-|xargs ls -t|tail -3) echo "eldest files ${files_toremove}" for backupfile in ${files_to_remove}; do echo "deleting backup ${backupfile}" rm -f "${backupfile}" done