Skip to content

Instantly share code, notes, and snippets.

@ageldama
Last active March 8, 2025 03:48
Show Gist options
  • Save ageldama/bd5ce35182908ae39f63e741c87fa228 to your computer and use it in GitHub Desktop.
Save ageldama/bd5ce35182908ae39f63e741c87fa228 to your computer and use it in GitHub Desktop.
s3에서 동영상 용량 모아보기
aws s3 ls files-dev --recursive >> s3-dev-ls.txt
aws s3 ls files-storage --recursive >> s3-prod-ls.txt
cat s3-dev-ls.txt | awk '{print $4}' | awk -F. '{print $NF}'|sort|uniq >> dev-exts.txt
cat s3-prod-ls.txt | awk '{print $4}' | awk -F. '{print $NF}'|sort|uniq >> prod-exts.txt
# ...이렇게 뽑은 dev-exts.txt prod-exts.txt을 편집하여 동영상 파일인 것으로 보이는 것들만 추려냄.
cat s3-dev-ls.txt|perl ./sum.pl
# ==> 19.696GiB
cat s3-prod-ls.txt|perl ./sum.pl
# ==> 715.127GiB
#!/usr/bin/env perl
use warnings;
use bigint;
BEGIN {
our $sum = 0;
}
END {
print qx/numfmt --to=iec-i --suffix=B --format="%.3f" $sum/, "\n";
}
while (<>) {
my @a = split /\s+/, $_;
my $size = $a[2] + 0;
my $name = $a[3];
if ($name =~ /asf|avi|DCM|m4a|mkv|mov|mp4|mpg|webp|wmv/i) {
$sum += $size;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment