Delete file when you have more than 100g for deleting

98

Hello Linix community members,

Today I would like to share a simple script for deleting files when you have more than 100g for deleting and when you try to delete using rm -rm /path/fo/files failed.

To do this I use the following procedure;

first I use a “for” ciclo to read file that I going to delete also you can use a mtime for calculate file’s date that you’re going to delete or you can to calculate previous date of a past day “x=`TZ=GMT+24 date +%Y%m%d`”

Ex;

#!/bin/bash -x
x=`TZ=GMT+24 date +%Y%m%d`
delcnt=0
for files in `find /path/of/file/to/eraser/ -name *$x*.bin.gz`
do
echo “Deleting file $files”
/bin/rm -rf $files
delcnt=$(($delcnt + 1))
done

 

Best regards

Charles E. Rivera

Solaris Server Specialist Engeeneer