Skip to content

Instantly share code, notes, and snippets.

@charles-hollenbeck
Created January 28, 2014 21:11
Show Gist options
  • Save charles-hollenbeck/8676586 to your computer and use it in GitHub Desktop.
Save charles-hollenbeck/8676586 to your computer and use it in GitHub Desktop.
Checks a directory's size and cleans it out if it's too large.
#!/bin/bash
size=$(du /home/charles/screenshots --bytes | grep '[0-9]*' -o)
max=$(expr 1024 \* 1024 \* 1024 \* 2)
if [[ "$size" -gt "$max" ]]; then
rm /home/charles/screenshots/*
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment