Last active
April 15, 2019 04:15
-
-
Save CMCDragonkai/e037ae78e370f73d52908113902a2032 to your computer and use it in GitHub Desktop.
Delete files/directories within a range of Unix timestamps #shell
This file contains 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
#!/usr/bin/env sh | |
# basically we go into a directory | |
# we list all immediate files/directories | |
# then we filter it by a numeric (timestamp) range | |
# and then we perform a deletion on them | |
unixtime-gc () { | |
find "$1" \ | |
-maxdepth 1 \ | |
-printf '%f\n' \ | |
| perl -ne \ | |
'print if $_ >= '$2' && $_ < '$3 \ | |
| xargs rm -r | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment