0

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?

Dhruv Patel
  • 426
  • 3
  • 9
  • 19
  • 2
    Possible duplicate of http://stackoverflow.com/questions/4760215/running-shell-command-from-python-and-capturing-the-output – slider Oct 05 '14 at 05:24
  • 1
    Why 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

0 Answers0