there is a bash script that searches for files, sorts and deletes

find $DIR -name "*.*" -and -type f | sort -r | tail -n1 | xargs -i rm -rf '{}' 

how to make the deleted files written to the file

    1 answer 1

     find $DIR -name "*.*" -and -type f | sort -r | tail -n1 | tee -a $FILENAME | xargs -i rm -rf '{}'