I want to read a file using grep system command in python by running this grep command through python and store the stdout in a python variable. How is this possible?
Asked
Active
Viewed 506 times
0
-
2Possible duplicate of http://stackoverflow.com/questions/4760215/running-shell-command-from-python-and-capturing-the-output – slider Oct 05 '14 at 05:24
-
1Why do you want to run grep in your Python script? Python has its own regex module, `re`, which is **much** more versatile than what you can do with grep. The regex syntax is similar, although Python doesn't support the character class shortcuts [:alnum:], [:alpha:], [:cntrl:], etc, but it does have equivalent syntax for the main ones. – PM 2Ring Oct 05 '14 at 08:24