Comment by masklinn

5 years ago

Not only is the intent of those snippets rather different, you've rather misunderstood the original to the extent that it's broken.

The bash version looks for the pattern `search` in every line of `test.txt`, the Python version treats `test.txt` as a file of patterns, and look for each of these patterns in the file `search`.

And of course you wouldn't implement the bash version in python that way as it's rather trivial to do it in Python:

    out = [line for line in open('test.txt') if 'search' in line]

or somesuch.