I am trying to use grep and pipe it to uniq to get unique results...(greping for ip addresses here)
process = subprocess.Popen(['grep','-sRIEho', '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}', '/tmp/test'])
p2 = subprocess.Popen(['uniq'],stdin=process.stdout)
stdout,stderr = p2.communicate()
The problem is that this hangs and doesn't show me unique results... Here's the '/tmp/test' file:
127.0.0.1
127.0.0.1
127.0.0.1
1.9.12.12
192.168.1.2
192.168.1.2
192.168.1.3
192.168.1.4
And the result well... It's the same Any idea what's happening here? Btw I cannot use Shell=True here (user supplied filename)