diff options
author | Dave Reisner <d@falconindy.com> | 2010-01-17 20:08:34 -0500 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2010-01-17 20:08:34 -0500 |
commit | 41c09161c890a53706e57279013716d28a28a2de (patch) | |
tree | e386525f111cb5172cfa2ac95c85c816c5407589 | |
parent | e3ff4b6496c961719de813fbe24dd39e62b15cc5 (diff) | |
download | squashfu-41c09161c890a53706e57279013716d28a28a2de.tar.gz |
Use preloaded array to generate report
-rwxr-xr-x | squashfu | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -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 () { |