Simple question for all of you python gurus
sean_berry at cox.net
Thu Feb 26 22:12:03 CET 2004
I am writing a little script to grep through a really long list of files and
look for a certain phrase.
I wanted to do something like this.
li = os.popen("/usr/bin/grep -i %s /home/%s/.tmda/pending" %(phrase,userid)
lis = li.readlines()
blah blah blah...
but even if I run this from the command line I get an error saying the
argument list is too long.
However, if I cd to /home/userid/.tmda/pending and then run the grep from
within the directory... it works great.
so I tried to do something like this
os.system("cd /home/%s/.tmda/pending" %userid)
li = os.popen("/usr/bin/grep -i %s" %phase)
lis = lis.readlines()
But since cd is a shell command, it does not seem to work either.
How can I do this?
Thanks in advance for answering this seemingly easy question.
More information about the Python-list