Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active January 11, 2022 11:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kou1okada/3d976853e9cc43da1ca556071d39519d to your computer and use it in GitHub Desktop.
Save kou1okada/3d976853e9cc43da1ca556071d39519d to your computer and use it in GitHub Desktop.
VirtualBox Disk Usage
#!/usr/bin/env bash
VBoxManage list hdds|sed -r -e 's/\r//g'|awk 'match($0,/^Location: *(.+)$/,m){fn=idx[0+n]=m[1];n++;"ls -ls '\''"fn"'\''"|getline; prop[fn,"alloc"]=$1*1024;prop[fn,"size"]=$6;}match($0,/^Capacity: /){prop[fn,"capacity"]=$2*1024*1024}END{printf("%15s %15s %15s %s\n", "capacity", "allocated", "size", "filename");for(i=0;i<n;i++){fn=idx[i]; printf("%'\''15d %'\''15d %'\''15d %s\n", prop[fn,"capacity"], prop[fn,"alloc"],prop[fn,"size"],fn)}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment