#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG 7.0a2				#
#							#
# Licensed under GNU LESSER GENERAL PUBLIC LICENSE v3	#
#							#
# Copyright 2007 - 2008 Christopher Bratusek		#
#							#
#########################################################

let TotalBytes=0

for Bytes in $(ls -lA -1 | grep "^-" | awk '{ print $5 }')
do
   let TotalBytes=$TotalBytes+$Bytes
done

# The if...fi's give a more specific output in byte, kilobyte, megabyte,
# and gigabyte

if [ $TotalBytes -lt 1024 ]; then
   TotalSize=$(echo -e "scale=1 \n$TotalBytes \nquit" | bc)
   suffix="b"
elif [ $TotalBytes -lt 1048576 ]; then
   TotalSize=$(echo -e "scale=1 \n$TotalBytes/1024 \nquit" | bc)
   suffix="kb"
elif [ $TotalBytes -lt 1073741824 ]; then
   TotalSize=$(echo -e "scale=1 \n$TotalBytes/1048576 \nquit" | bc)
   suffix="Mb"
else
   TotalSize=$(echo -e "scale=1 \n$TotalBytes/1073741824 \nquit" | bc)
   suffix="Gb"
fi

echo -n "${TotalSize}${suffix}"
