linux - 如何在 bash 脚本中使用 find 命令检查目录大小
问题描述
我需要找到大于特定值的目录大小,我为此编写了一个脚本。但是 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 {} \;
推荐阅读
- php - 无法将最大文件大小上传增加到 2gb 以上
- python - 误差条和 seaborn 散点图中的颜色不匹配
- reactjs - 如何在悬停更改时更改 Material-UI MenuItem 背景?
- r - 从字符串中选择每第 n 个字符
- python - 文本到 csv 转换器
- javascript - Ace Editor 试图从错误的目录中获取主题
- utf-8 - 如何修复 Microsoft SQL Server Management Studio v18 中 UTF-8 数据的不一致显示并正确处理这些数据?
- r - 我无法为点添加标签 - 足球场
- arrays - 将数字与C中的多维数组匹配
- css - 在 JSfiddle 中它为什么不喜欢我的 CSS 中的 @keyframes?