title: How to parse a CLI command output (table) in python?
body: <p>I am a newbie to parsing. </p>
  
  <pre><code>switch-630624 [standalone: master] (config) # show interface ib status
  
  Interface      Description                                Speed                   Current line rate   Logical port state   Physical port state
  ---------      -----------                                ---------               -----------------   ------------------   -------------------
  Ib 1/1                                                    14.0 Gbps rate          56.0 Gbps           Initialize           LinkUp
  Ib 1/2                                                    14.0 Gbps rate          56.0 Gbps           Initialize           LinkUp
  Ib 1/3                                                    2.5 Gbps rate only      10.0 Gbps           Down                 Polling
  </code></pre>
  
  <p>Assume I have an engine which injects the command on the switch, and put the above output as 1 huge string in a variable named "output". </p>
  
  <p>I would like to return a dictionary which includes only the ports number as follows:</p>
  
  <pre><code>{'Ib1/11': '1/11', 'Ib1/10': '1/10', ... , }
  </code></pre>
  
  <p>I guess I should use the Python`s Subprocess module and regular expressions. </p>
  
  <p>Number of ports can vary (can be 3, 10, 20, 30, 60...).</p>
  
  <p>I will appreciate any kind of direction.</p>
  
  <p>Thanks, </p>
  
  <p>Qwerty</p>