Add new tool dirsize.sh

This commit is contained in:
Ze'ev Schurmann 2023-10-27 10:53:45 +02:00
parent 009de60f5f
commit ce641135eb
1 changed files with 23 additions and 0 deletions

23
dirsize/dirsize.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
if [[ -f "/tmp/dir.list" ]]; then
rm "/tmp/dir.list"
fi
if [[ -f "/tmp/dir.list" ]]; then
echo "Couldn't delete the temp file from a previous run."
echo "As root please run..."
echo
echo "# rm /tmp/dir.list"
echo
echo "or use sudo..."
echo
echo "$ sudo rm /temp/dir.list"
echo
exit 1
fi
find . -maxdepth 1 -type d > "/tmp/dir.list"
while read -r foldername; do
if [[ $foldername != "." ]]; then
du -h $foldername | tail -1
fi
done < "/tmp/dir.list"
rm "/tmp/dir.list