Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Last active April 15, 2019 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CMCDragonkai/e037ae78e370f73d52908113902a2032 to your computer and use it in GitHub Desktop.
Save CMCDragonkai/e037ae78e370f73d52908113902a2032 to your computer and use it in GitHub Desktop.
Delete files/directories within a range of Unix timestamps #shell
#!/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