-
-
Save radut/6cb357f5ae1fb81b0c194da063281fc1 to your computer and use it in GitHub Desktop.
Revisions
-
JProffitt71 created this gist
Feb 17, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #!/bin/bash # Usage: ./s3cmdclearfiles "bucketname" "30d" s3cmd ls s3://$1 | grep " DIR " -v | while read -r line; do createDate=`echo $line|awk {'print $1" "$2'}` createDate=`date -j -f "%Y-%m-%d %H:%M" "$createDate" +%s` olderThan=`date -j -v-$2 +%s` if [[ $createDate -lt $olderThan ]] then fileName=`echo $line|awk {'print $4'}` if [[ $fileName != "" ]] then printf 'Deleting "%s"\n' $fileName s3cmd del "$fileName" fi fi done;