From 5af2e2d73b52602a264d53ce84077406d94c7ef9 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 6 Dec 2008 00:29:07 -0600 Subject: [PATCH] Add total MB free'd to output of 'remove-unused-sources' script. --- remove-unused-sources | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/remove-unused-sources b/remove-unused-sources index 42737fd..8769d8f 100755 --- a/remove-unused-sources +++ b/remove-unused-sources @@ -56,17 +56,32 @@ set_diff () remove_sources () { + local TOTAL=0 local FILE + local SIZE while read FILE do - if [ $DRY_RUN = yes ] + + SIZE=`stat -c '%s' "${FILE}" 2>/dev/null` + + if [ $? -ne 0 ] then - echo "Would remove: ${FILE}" + echo "Would remove \"${FILE}\", if it existed." else - echo "Removing unused source \"${FILE}\"..." - rm -f ./"${FILE}" ./"${FILE}-"*.peak + if [ $DRY_RUN = yes ] + then + echo "Would remove: ${FILE}" + else + echo "Removing unused source \"${FILE}\"..." + rm -f ./"${FILE}" ./"${FILE}-"*.peak + fi + + TOTAL=$(( $TOTAL + $SIZE )) fi + done + + echo "...Freeing a total of $(($TOTAL / ( 1024 * 1024 ) ))MB" } [ $# -gt 0 ] || fatal "Usage: $0 [--dry-run] path/to/project"