title: Python3 subprocess output
body: <p>I want to run the Linux word count utility wc to determine the number of lines currently in the /var/log/syslog, so that I can detect that it's growing.  I've tried various test, and while I get the results back from wc, it includes both the line count as well as the command (e.g., var/log/syslog).</p>
  <p>So it's returning:
  1338 /var/log/syslog
  But I only want the line count, so I want to strip off the /var/log/syslog portion, and just keep 1338.</p>
  <p>I have tried converting it to string from bytestring, and then stripping the result, but no joy.  Same story for converting to string and stripping, decoding, etc - all fail to produce the output I'm looking for.</p>
  <p>These are some examples of what I get, with 1338 lines in syslog:</p>
  <ul>
  <li>b'1338 /var/log/syslog\n'</li>
  <li>1338 /var/log/syslog</li>
  </ul>
  <p>Here's some test code I've written to try and crack this nut, but no solution:</p>
  <pre><code>import subprocess
  
  #check_output returns byte string
  stdoutdata = subprocess.check_output(&quot;wc --lines /var/log/syslog&quot;, shell=True)
  print(&quot;2A stdoutdata: &quot; + str(stdoutdata))
  stdoutdata = stdoutdata.decode(&quot;utf-8&quot;)
  print(&quot;2B stdoutdata: &quot; + str(stdoutdata))    
  stdoutdata=stdoutdata.strip()
  print(&quot;2C stdoutdata: &quot; + str(stdoutdata))    
  </code></pre>
  <p>The output from this is:</p>
  <ul>
  <li><p>2A stdoutdata: b'1338 /var/log/syslog\n'</p>
  </li>
  <li><p>2B stdoutdata: 1338 /var/log/syslog</p>
  </li>
  <li><p>2C stdoutdata: 1338 /var/log/syslog</p>
  </li>
  <li><p>2D stdoutdata: 1338 /var/log/syslog</p>
  </li>
  </ul>