This repository has been archived on 2025-12-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
qmi-cloud/qmi-cloud-cli/shell-utils/cost.sh
2020-07-09 12:57:38 +02:00

24 lines
769 B
Bash

# LOGIN
az login --identity
BASEDIR=$(dirname "$0")
SUBS="62ebff8f-c40b-41be-9239-252d6c0c8ad9"
CONTAINER="exports"
STORAGEACCOUNT="qmiexports"
STORAGEACCOUNTKEY="6PI/qNoJ7UnX83lVcffN7p7X1TwYXv+jHKLIEcMKZWpWA01Vj75AAyjq4dXJdmUgCeSEIRefHnJzQeuPZRHInQ=="
# GET FILES
az storage blob download-batch --destination . --source $CONTAINER --account-name $STORAGEACCOUNT --account-key $STORAGEACCOUNTKEY --pattern *.csv --subscription $SUBS
# MOVE LATEST FILE PER MONTH TO FOLDER latest
echo "BASEDIR=$BASEDIR"
for d in "$BASEDIR/qmicloud/qmicloud/"*
do
folderBase=$(basename "$d")
ymn=$(echo $folderBase | cut -c1-6)
lastFile=$(find $d -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ")
echo $lastFile
cp $lastFile $BASEDIR/$ymn.csv
done