我意識到這可能是一個非常簡單的問題,但我無法弄清楚爲什麼這不起作用。我試圖檢查一個文件夾是否大於35GB,如果是,請刪除所有超過3天的文件。Bash條件語句
有了這個代碼:
#!/bin/bash
MAX=35000000000
if [ $(du -sb ~/MEGA | cut -f1) \> $MAX ] then
find ~/MEGA/* -mtime +3 -exec rm -fr {} \;
fi
,我發現了以下錯誤:
syntax error near unexpected token `fi'
看看http://www.shellcheck.net/ – Cyrus
@Cyrus真棒! – codedude