import re
for i in list(open("/etc/passwd")):
m=re.search(r"^\broot\b", i)
if m:
print i
....:
root:x:0:0:root:/root:/bin/bash
python grep users from passwd
Leave a reply
import re
for i in list(open("/etc/passwd")):
m=re.search(r"^\broot\b", i)
if m:
print i
....:
root:x:0:0:root:/root:/bin/bash