DEV Community

Discussion on: Script to clean out files in dir and have a note of deleted files in deleted_files.log

Collapse
 
bobbyiliev profile image
Bobby

Looks good! Can you also share the code itself here as well so people could copy it easier?

Collapse
 
sunilvijay profile image
Sunil Vijay • Edited

TIMESTAMP=date +%F

echo "Auto Generate Log files"
find /home/ubuntu/audios/ -name 'audio*' -mmin +2880 -exec bash -c ' echo "{} - " date -r {} rm -rf {} ' \; | xargs > deleted-files-$TIMESTAMP.log
echo "Log Generated Successfully"

Collapse
 
sunilvijay profile image
Sunil Vijay

Thanks Bobby. The code is above in the snippet.