Closed rustyrazorblade closed 8 months ago
lsblk supports JSON output with the -J flag, and we have yq installed, so we can do quite a bit with it.
Examples:
$ lsblk -o NAME,MOUNTPOINTS -J | yq '.blockdevices[] ' {"name": "loop0", "mountpoints": ["/snap/core18/2812"]} $ lsblk -o NAME,MOUNTPOINTS -J | yq '.blockdevices[] | select(.name == "nvme1n1") | length ' 2 $ lsblk -o NAME,MOUNTPOINTS -J | yq '.blockdevices[] | select(.name == "nvme1n1") ' {"name": "nvme1n1", "mountpoints": [null]} $ lsblk -o NAME,MOUNTPOINTS -J | yq '.blockdevices[] ' {"name": "loop0", "mountpoints": ["/snap/core18/2812"]} {"name": "loop1", "mountpoints": ["/snap/core20/2182"]} {"name": "loop2", "mountpoints": ["/snap/lxd/27037"]} {"name": "loop3", "mountpoints": ["/snap/amazon-ssm-agent/7628"]} {"name": "loop4", "mountpoints": ["/snap/lxd/27428"]} {"name": "loop5", "mountpoints": ["/snap/snapd/20671"]} {"name": "loop6", "mountpoints": ["/snap/snapd/21184"]} {"name": "nvme1n1", "mountpoints": [null]} {"name": "nvme0n1", "mountpoints": [null], "children": [{"name": "nvme0n1p1", "mountpoints": ["/"]}, {"name": "nvme0n1p14", "mountpoints": [null]}, {"name": "nvme0n1p15", "mountpoints": ["/boot/efi"]}]}
Addressed in 91c3564eaeb52fd82214c5d3a7136a04597f1b1a
lsblk supports JSON output with the -J flag, and we have yq installed, so we can do quite a bit with it.
Examples: