Last active
January 11, 2022 11:53
-
-
Save kou1okada/3d976853e9cc43da1ca556071d39519d to your computer and use it in GitHub Desktop.
VirtualBox Disk Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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