From ce641135eb5a028109415adbbeb9b0dd680716c1 Mon Sep 17 00:00:00 2001 From: Ze'ev Schurmann Date: Fri, 27 Oct 2023 10:53:45 +0200 Subject: [PATCH] Add new tool dirsize.sh --- dirsize/dirsize.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 dirsize/dirsize.sh 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