Created
August 31, 2012 03:02
-
-
Save granolocks/3548413 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # This checks that the specified file is less than 4 days old | |
| # deletes files that are too old | |
| for f in *.jpg | |
| do | |
| FILE=$f | |
| MAXAGE=$(bc <<< '4*24*60*60') # seconds in a week | |
| #MAXAGE=$(bc <<< '60') # seconds in a minute, for testing | |
| ## file age in seconds = current_time - file_modification_time. | |
| FILEAGE=$(($(date +%s) - $(stat -c '%Y' "$FILE"))) | |
| test $FILEAGE -gt $MAXAGE && { | |
| rm $FILE | |
| } | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment