0

I'm trying to use the subprocess command to get a variable defined without spitting stdout, but it's not working as intended.

import subprocess

p1 = subprocess.run('ls -lrth /my/data/dir/table.ibd | awk \'{print $5}\'', shell=True, stdout=None)

print ("{0} is the best player.".format(p1))

I'm trying to avoide ths os library and use subprocess to gather my output.

The output:

79G
CompletedProcess(args="ls -lrth /my/data/dir/table.ibd | awk '{print $5}'", returncode=0) is the size of the table.

I want this suppressed, obviously to say "79G is the size of the table." There also shouldn't be any white space before or after the result.

user3299633
  • 2,971
  • 3
  • 24
  • 38

0 Answers0