Date: Fri, 7 Dec 2012 00:54:56 -0600 From: James <james@hicag.org> To: freebsd-questions@freebsd.org Subject: Re: List all hard drives on system (with capacities)... How? Message-ID: <CAD4099mKGf%2B3tkiWHJfKw6RYaJKajy1AZyk2chWb=Jrk%2B-QhUA@mail.gmail.com> In-Reply-To: <20121207062431.GA15665@hemlock.hydra> References: <50C1313C.4000201@gmx.com> <11844.1354839834@tristatelogic.com> <20121207062431.GA15665@hemlock.hydra>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAD4099mKGf%2B3tkiWHJfKw6RYaJKajy1AZyk2chWb=Jrk%2B-QhUA>
