title: How to Extract some Fields from Real Time Output of a Command in Bash script
body: <p>I want to extract some fields out of output of command <code>xentop</code>. It's like <code>top</code> command; provides an ongoing look at cpu usage,memory usage,...in real time.
  If I run this command in batch mode, I will have its output as you see in a file:</p>
  
  <pre><code>      NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR  VBD_RSECT  VBD_WSECT SSID
    Domain-0 -----r      13700   33.0    7127040   85.9   no limit       n/a     8    0        0        0    0        0        0        0          0          0    0
       fed18 -----r        738  190.6    1052640   12.7    1052672      12.7     3    1   259919     8265    1        0    82432    22750    2740966    1071672    0
  </code></pre>
  
  <p>and running this</p>
  
  <pre><code>cat file| tr '\r' '\n' | sed 's/[0-9][;][0-9][0-9][a-Z]/ /g' | col -bx | awk '{print $1,$4,$6}'
  </code></pre>
  
  <p>on this file gives me what I want</p>
  
  <pre><code>NAME CPU(%) MEM(%)
  Domain-0 33.0 85.9
  fed18 190.6 12.7
  </code></pre>
  
  <p>but my script doesn't work on realtime output of xentop. I even tried to just run xentop one time by setting itteration option as 1(<code>xentop -i 1</code>) but It does not work!
  How can I pipe output of xentop as "not" realtime to my script?  </p>