簡體   English   中英

如何在bash腳本中使用find命令檢查目錄大小

[英]how to check the directory size using find command in bash script

我需要找到大於特定值的目錄大小,我為此編寫了一個腳本。 但是 find 命令不接受 -size 部分。 誰可以幫我這個事

echo -e "This script will generate report for directories which consumes more size than the given value"
read -p " Enter the file system or directory full path: " path
read -p " This script will check the directories which is greater than the given size Please Enter the directory size in GB: " size
find $path  -type d -size +$sizeG -exec ls -ld {} \;

錯誤

find: invalid -size type `+'

為了消除bash腳本中的壞替換錯誤。 用雙配額包裝可變大小。

    echo -e "This script will generate report for directories which consumes more size than the given value"

read -p " Enter the file system or directory full path: " path
read -p " This script will check the directories which is greater than the given size Please Enter the directory size in GB: " size

echo "+${size}G";

find $path  -type d -size "+${size}G" -exec ls -ld {} \;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM