And because I think geom(8) and awk(1) are awesome...

geom disk list | awk '
BEGIN { FS=": *" }
$1 == "Geom name" { device=$2 }
$1 ~ "^ +Mediasize$" {
        match($2, /\([^)]+\)/)
        size=substr($2, RSTART+1, RLENGTH-2)
}
$1 ~ "^ +descr$" {
        if ($2 == "(null)") {
                descr="UNKNOWN"
        } else {
                descr=$2
                gsub(/ /, "_", descr)
        }
}
/^$/ {
        if (device !~ /^cd[0-9]+/) {
                printf "%s %s %s\n", device, size, descr
        }
}
'

This likely won't handle every possible device type available.
Something very similar is serving me well thus far.

HTH!

-- 
James.
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to