title: efficient way to parse vmstat output
body: <p>I'm trying to efficiently parse vmstat output preferably in awk or sed, it also should work on both linux and hp-ux. For example I would like to cut cpu idle % ("92" in this case) from the following output:</p>
  
  <pre><code>$ vmstat
  procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
   r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
  11  0 385372 101696  61704 650716    0    1     5     9    6   12  5  2 92  0
  </code></pre>
  
  <p>unfortunately the vmstat output can differ on different linux distributions and hp-ux, also  columns can vary in length and can be presented in other order.</p>
  
  <p>I tried to write some nice awk oneliner, but eventually ended with python solution:</p>
  
  <pre><code>$ vmstat | python -c 'import sys; print dict(zip(*map(str.split, sys.stdin)[-2:])).get("id")'
  92
  </code></pre>
  
  <p>Do you know better way to parse mentioned output, to get number values of desired column name?</p>