I am looking forward to create a unix shell script to purge the files.
The requirement is:
1) Do df -k and check the current space occupied for the /a1 folder.
2) If the space consumed is greater than 90 %, delete all the DEF* files from a subfolder /a1/archive.
Example:
df -k results in:
/dev/lv02 4194304 412292 91% 94883 10% /a1
Since the space is consumed > 90 % (91% in this case), the following files needs to be deleted:
used=$( df -k "/a1" | awk 'NR > 1 { sub("%",X,$4); print $4 } ' ) # Get used percentage for folder: a1
if [ $used -gt 90 ] # Check if it is greater than 90
then
echo rm -f /a1/ARCHIVE/DEF*.txt # If yes, remove all /a1/ARCHIVE/DEF*.txt files
fi