-
-
Save deltamualpha/9918757 to your computer and use it in GitHub Desktop.
A one-liner to delete the crud files that s3fs leaves in your mounted s3 directories after you've quit using s3fs
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
s3cmd ls --recursive s3://BUCKET_NAME |\ | |
ruby -rdate -ne 'date, time, size, uri = $_.split; puts uri if size == "0" && uri[-1,1] != "/" && !uri.include?(".")' |\ | |
xargs s3cmd del |
Updates to exclude files with a dot in them -- mostly site-specific, but we have a few 0-byte files that are not s3fs-related that this catches and ignores.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
uri[-1,1] != "/"
bit is to avoid passing "empty" "folders" tos3cmd del
.Both of those air-quotes are accurate and silly.