diff --git a/dirsize/dirsize.sh b/dirsize/dirsize.sh new file mode 100644 index 0000000..579d00c --- /dev/null +++ b/dirsize/dirsize.sh @@ -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