This is an old revision of the document!
Write a python3 script that receives a list of files from stdin (one per line) and an arbitrary number of words as command line arguments. The script must search for these words in each file and output each line that contains at least one of them in this format:
<file_name>:<line_number>:<line>
Note that if a line contains more than one word, it still must appear only once in your output. Your program should be run like this:
$ find . | ./my_grep.py import for sys
Use any commands that you have learned in this or any other lab to compare your implementation to that grep (at least one must be related to I/O). Test case:
$ find /usr/include/ | ./my_grep.py int include define for $ grep -rn "int\|include\|define\|for" /usr/include/ $ grep -Frn -f <(echo "int\ninclude\ndefine\nfor") /usr/include
What algorithm does grep use? How does grep -F differ from fgrep?
Read up a bit about Aho-Corasick. Explain to your assistant how it works.