Delete Google Cloud Storage date named items on Mac & CentOS
Sun, 02 April 2017
centos_version.sh
#!/bin/bash # assumes file or directory name looks like: "file_starts_with_2017-03-23" BUCKET_NAME="my_bucket_name" FILE_PREPEND_NAME="file_starts_with" for i in `seq 30 90`; do NEW_DATE=`date --date "-${i} days" +%Y-%m-%d` NAME="${FILE_PREPEND_NAME}_${NEW_DATE}" gsutil -m rm -r gs://$BUCKET_NAME/$NAME done
mac_version.sh
#!/bin/bash # assumes file or directory name looks like: "file_starts_with_2017-03-23" BUCKET_NAME="my_bucket_name" FILE_PREPEND_NAME="file_starts_with" for i in `seq 30 90`; do NEW_DATE=`date -j -v"-${i}d" +%Y-%m-%d` NAME="${FILE_PREPEND_NAME}_${NEW_DATE}" gsutil -m rm -r gs://$BUCKET_NAME/$NAME done