![5日以上古いディレクトリを削除するBashスクリプトが必要ですか? [閉鎖]](https://linux33.com/image/9552/5%E6%97%A5%E4%BB%A5%E4%B8%8A%E5%8F%A4%E3%81%84%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%82%92%E5%89%8A%E9%99%A4%E3%81%99%E3%82%8BBash%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%8C%E5%BF%85%E8%A6%81%E3%81%A7%E3%81%99%E3%81%8B%EF%BC%9F%20%5B%E9%96%89%E9%8E%96%5D.png)
#!/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)) ]