aboutsummaryrefslogtreecommitdiffstats
path: root/squashfu
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2010-01-17 20:08:34 -0500
committerDave Reisner <d@falconindy.com>2010-01-17 20:08:34 -0500
commit41c09161c890a53706e57279013716d28a28a2de (patch)
treee386525f111cb5172cfa2ac95c85c816c5407589 /squashfu
parente3ff4b6496c961719de813fbe24dd39e62b15cc5 (diff)
downloadsquashfu-41c09161c890a53706e57279013716d28a28a2de.tar.gz
Use preloaded array to generate report
Diffstat (limited to 'squashfu')
-rwxr-xr-xsquashfu15
1 files changed, 9 insertions, 6 deletions
diff --git a/squashfu b/squashfu
index 9e25cc8..0ae8c65 100755
--- a/squashfu
+++ b/squashfu
@@ -316,20 +316,23 @@ action_report () {
info "SquashFu Usage Report"
echo
# Enumerate bins, sort date order, print human readable create date and size
+
OLDIFS=$IFS;IFS=${IFS}:
+ # Collect all data into an array to 'preload' it. Index 0 is the entire
+ # folder. The following indicies correspond to the bin number of that index
+ DATA=($(du -sh ${BINS_DIR} ${BINS_DIR}/* 2>/dev/null | awk '{print $1}'))
+
printf "%10s\t%25s\t%7s\n" "Bin ID" "Date Created" "Size"
grep -vE "^[\t ]*$" "$BINVENTORY" | sort -r -t: -k2 -n | while read bin stamp; do
- printf "%10d\t%25s\t%7s\n" $bin \
- "$(date --rfc-3339=seconds --date="1970-01-01 $stamp sec GMT")" \
- "$(du -sh ${BINS_DIR}/$bin 2>/dev/null | awk '{print $1}')"
+ printf "%10d\t%25s\t%7s\n" "$bin" "$(date --rfc-3339=seconds --date="1970-01-01 $stamp sec GMT")" "${DATA[$bin]}"
done
IFS=$OLDIFS
- printf "%10s\t%25s\t%7s\n" "" "Incremental Total" "$(du -sh "$BINS_DIR" 2>/dev/null | awk '{print $1}')"
+ printf "%10s\t%25s\t%7s\n" "" "Incremental Total" "${DATA[0]}"
# Print totals (not efficient -- reruns du on things we already ran it on)
- printf "\n%10s\t%25s\t%7s\n" "" "$(basename $SEED)" "$(du -h "$SEED" 2>/dev/null | awk '{print $1}')"
+ printf "\n%10s\t%25s\t%7s\n" "" "$(basename $SEED)" "${DATA[0]}"
printf "\n%10s\t%25s\t%7s\n" "" "Grand Total" \
- "$(du -csh "$BINS_DIR" "$SEED" 2>/dev/null | grep -E "total$" | awk '{print $1}')"
+ "$(du -csh "$BINS_DIR" "$SEED" 2>/dev/null | grep -E "total$" | awk '{print $1}')"
}
action_resquash_now () {