Skip to content

Instantly share code, notes, and snippets.

@alaq
Created May 22, 2017 13:54
Show Gist options
  • Save alaq/592473cf7b85d600e819e04d15bab747 to your computer and use it in GitHub Desktop.
Save alaq/592473cf7b85d600e819e04d15bab747 to your computer and use it in GitHub Desktop.
Tally up data added within a day, total bytes, and human readable format
#!/bin/bash
# Change folder and output below
# Run with @daily cron
folder=YOUR FOLDER
output=YOUR OUTPUT FILE
today=`date +%Y-%m-%d -d "yesterday"`
sum=$(find $folder -mtime -1 -printf "%s\n"|awk '{t+=$1}END{print t}')
readablesum=$(numfmt --to=iec $sum)
echo "$today $sum $readablesum" >> $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment