یابنده فایلهای بزرگ
اسکریپتی که فایلهای بزرگتر از اندازه مشخص شده را پیدا و فهرست میکند. برای مدیریت فضای دیسک مفید است.
منتشر شده: 2024/05/03
کد
#!/bin/bash
# Large File Finder
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <directory> <size>"
echo "Example: $0 /home 100M"
echo "Size formats: K (kilobytes), M (megabytes), G (gigabytes)"
exit 1
fi
DIR="$1"
SIZE="$2"
if [ ! -d "$DIR" ]; then
echo "Error: Directory not found: $DIR"
exit 1
fi
echo "Finding files larger than $SIZE in $DIR..."
echo ""
find "$DIR" -type f -size +$SIZE -exec ls -lh {} \; | awk "{print \$5, \$9}" | sort -hr
echo ""
echo "Scan completed!"
نحوه استفاده
chmod +x find_large_files.sh
./find_large_files.sh /home 100M