1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OCI ObjectStorage フォルダー内の容量を確認する

Posted at

概要

Oracle Cloud Infrastructure(OCI)のObject Storage内のフォルダ内にあるファイルの数と合計サイズを取得するShellです

前提

以下のサービスを利用したことがあることを前提としています

  • OCI CLIが利用可能
  • jqがインストールされている

準備

Shell

oslistsize.sh
#!/bin/bash

# Count size key
count=$(oci os object list -bn $1 --prefix $2 --limit 10000 | jq -r '.data[] | ."size"' | wc -l )

# Extract size and calculate total
sizes=$(oci os object list -bn $1 --prefix $2 --limit 10000 | jq -r '.data[] | ."size"' )

total_size=0
for size in $sizes; do
  total_size=$((total_size + size))
done

# Show results
echo "Count: $count"
echo "Total size: $total_size byte"

実行

バケット名およびフォルダ名を指定して実行するとフォルダを含むオブジェクト数とサイズ合計が表示されます

[user@linux]$ /bin/bash oslistsize.sh <bucket name> <folder name>
Count: 10
Total size: 26836 byte

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?