Check folder size in Bash

前端 未结 8 810
情深已故
情深已故 2020-12-12 08:50

I\'m trying to write a script that will calculate a directory size and if the size is less than 10GB, and greater then 2GB do some action. Where do I need to mention my fol

8条回答
  •  遥遥无期
    2020-12-12 09:39

    Use a summary (-s) and bytes (-b). You can cut the first field of the summary with cut. Putting it all together:

    CHECK=$(du -sb /data/sflow_log | cut -f1)
    

提交回复
热议问题