Python – how to execute shell commands with pipe, but without ‘shell=True’?

>>> import subprocess

>>> mycmd=subprocess.getoutput('df -h | grep home | gawk \'{ print $1 }\' | cut -d\'/\' -f3')

>>> mycmd 

'sda6'

>>>

Leave a Comment