[EMAIL PROTECTED] wrote: > So I need to recursively grep a bunch of gzipped files. This can't be > easily done with grep, rgrep or zgrep. (I'm sure given the right > pipeline including using the find command it could be done....but > seems like a hassle). > > So I figured I'd find a fancy next generation grep tool. Thirty > minutes of searching later I find a bunch in Perl, and even one in > Ruby. But I can't find anything that interesting or up to date for > Python. Does anyone know of something?
I don't know of anything in Python, but it should be straight-forward to write, and I'm betting somebody in this group can do it in one line. (Did you see Arnaud's solution on the "Interesting math problem" thread?) When you say "recursively," do you mean that you want to grep files in nested subdirectories, or do you mean that archive elements should in turn be expanded if they are themselves archives? If you encounter a file that has been compressed twice (gzip|gzip), do you want to uncompress it repeatedly until you get to the original file? For example, given the following setup, what do you expect the output of my_grep to be? ~$ mkdir sample && cd sample sample$ for w in hello world; do echo $w |gzip -c >$w.gz; done sample$ tar czf helloworld.tgz *.gz sample$ my_grep hello -r . -- http://mail.python.org/mailman/listinfo/python-list