df -Ph | \
jq -R -s '
[
split("\n") |
.[] |
if test("^/") then
gsub(" +"; " ") | split(" ") | {mount: .[0], spacetotal: .[1], spaceavail: .[2]}
else
empty
end
]'
# output:
[
{
"mount": "/dev/mapper/vgubuntu-root",
"spacetotal": "468G",
"spaceavail": "52G"
},
{
"mount": "/dev/loop1",
"spacetotal": "56M",
"spaceavail": "56M"
}
}
Created
May 6, 2021 13:30
-
-
Save dorokhin/ad0a5dd548a38792c27eb24ba03ad179 to your computer and use it in GitHub Desktop.
Disk space to json
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment