Image by Gratisography

I got bored and have a bunch of junk that lives in a folder on the web server and really needed to know how much junk is actually there, on a daily basis, so I threw together this piece of garbage.

#!/bin/bash
SIZE=`du -s /path/to/files | awk {'print $1'}`
HSIZE=`du -sh /path/to/files | awk {'print $1'}`
FCOUNT=`ls /path/to/files | wc -l`

echo -e \"Total size: ${SIZE} bytes (${HSIZE})\
<br>File count: ${FCOUNT}\"

It outputs:

Total size: [size] bytes ([human readable size])
File count: [count]

Throw that sucker into a crontab, and you're golden.

@hourly /path/to/stats.sh > /var/www/html/stats.html 

I guess you can replace @hourly with 0 */24 * * * or something? Whatever.

I had more issues remembering how to assign variables in bash than anything else.

Flippin' whitespace.


As per the norm, header image by [Gratisography][gratis].