5日以上古いディレクトリを削除するBashスクリプトが必要ですか? [閉鎖]

5日以上古いディレクトリを削除するBashスクリプトが必要ですか? [閉鎖]
#!/bin/bash

exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>>/var/log/folderpurge.log 2>&1

date

###########################
# Self Explanatory printf #
###########################
if [[ ! $EUID == 0 ]]; then
    echo "This script must be run as root."
    exit 1
fi

########################################################################
# Check the current local(nix) folder size before initiating the purge #
########################################################################
if [ -e /home/s3user/extractedISOs/ ] && [ $(du -hsm    /home/s3user/extractedISOs | awk '{print $1}' -gt $((1024*50)) ]
then 
    echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
    echo "| The extractedISOs folder exists and it is greater than 50GB |"
    echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
    echo "++++++++++++++++++++"
    echo "| INITIATING PURGE |"
    echo "++++++++++++++++++++"
    #foldpurg=$(find /home/s3user/extractedISOs/* -type d -ctime +5 -exec rm -rf {} \;);
    foldpurg=$(find /home/s3user/extractedISOs/* -type d -ctime +5 | xargs rm -rf);
else
    exit
fi

exit 0


**Error at line 20 and 35?** 

ベストアンサー1

私が間違えない限り、duのお問い合わせは閉じ括弧がありません。

[ $(du -hsm    /home/s3user/extractedISOs | awk '{print $1}' -gt $((1024*50)) ]

次は動作します。

[ $(du -hsm    /home/s3user/extractedISOs | awk '{print $1}' ) -gt $((1024*50)) ]

おすすめ記事