import subprocess
cat = subprocess.Popen(['cat', 'subprocess_signal_setsid.py'],
stdout=subprocess.PIPE,
)
grep = subprocess.Popen(['grep', 'subprocess'],
stdin = cat.stdout,
stdout = subprocess.PIPE,
)
cut = subprocess.Popen(['cut', '-f','3','-d:'],
stdin=grep.stdout,
stdout=subprocess.PIPE,
)
end_of_pipe = cut.stdout
print 'Included files:'
for line in end_of_pipe:
print '\t', line.strip()
# cat subprocess_signal_setsid.py |grep "subprocess"|cut -f 3 -d:
执行结果: