Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Oct 2009 07:47:54 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        grarpamp <grarpamp@gmail.com>
Subject:   Re: vmstat -m/-z field parsing
Message-ID:  <200910150747.55101.jhb@freebsd.org>
In-Reply-To: <d2e731a10910142324n5b538e4bp9dc782eae8ee46d6@mail.gmail.com>
References:  <d2e731a10910142324n5b538e4bp9dc782eae8ee46d6@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 15 October 2009 2:24:00 am grarpamp wrote:
> Some of the 'first' columns in the
> output contain spaces which makes
> it hard to parse the data out. Unless I'm
> missing the reason, I propose they be
> changed to underscores '_' as
> per the rest of the ouput. Thanks.

You can also just not use whitespace for your field separator.  For example
with awk and sort:

vmstat -z | awk -F '[:,]' '/ITEM/ { next } /^$/ { next } // { printf "%s:\t%d\n", $1, $2 * ($4 + $5) }' | sort -t: -k 2 -n 

(This computes the total size of allocated memory (both used and free items)
for a zone and sorts the list so the biggest zones are last.)

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910150747.55101.jhb>