I am learning python and writing a small script. I need my output to be in a file and also print the output on the screen as well.I tried various methods like stdout=subprocess.PIPE
i could not figure out outputting to both.please forgive me for this silly question`
#!/usr/bin/python
import os
import subprocess
with open('/root/test/testfile') as f , open('aaa.txt',"w") as final:
content = f.read().splitlines()
for x in content:
result= subprocess.Popen(['grep',x,'/news/today/night/logs'],stdout=final)