I have a python program that will cat a file and then print out the output only if the word "oranges" is found in the output. I was wondering how I could reverse this and have the program NOT output anything if "oranges" is found in the output?
import commands, os, string
from subprocess import Popen, PIPE
cmd = "cat /root/newfile.txt"
args = shlex.split(cmd)
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if out.find("oranges") > -1:
if not "oranges" in out: print out