[Tutor] Searching 2 Strings in A File

Prasad, Ramit ramit.prasad at jpmorgan.com
Wed Jun 6 21:49:58 CEST 2012


> >     x = "Device " + sys.argv[1] + " restored the database"
> >     y = "Created connection to " + sys.argv[1]
> >
> >     cmd_line = Popen(["egrep", "(x,y)", aLogFile], stdout=PIPE, stdin=PIPE,
> > stderr=STDOUT)
> >
> > the above code does not work because it will look for x and y in aLogFile
> > instead of
> > looking for <"Device " + sys.argv[1] + " restored the database"> and
> <"Created
> > connection to " + sys.argv[1]>
> > Any hint is appreciated.
> 
> Try
> 
> pattern = "({0},{1})".format(x, y)
> cmd_line = Popen(["egrep", pattern, aLogFile], stdout=PIPE, stdin=PIPE,
> stderr=STDOUT)

Also, I think it should be '|' in pattern and not ','. 

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  


More information about the Tutor mailing list