PYTHON: Write a program that takes a keyword and one or more file names on the command line. Then for each file specifie
Posted: Fri Apr 29, 2022 7:11 am
PYTHON: Write a program that takes a keyword and one or more
file names on the command line. Then for each file specified by
each filename, print out every line that contains the keyword --
following the format shown below.
E.g.,
% python find.py Foobar report.txt address.txt
homework.py
might result in the following output:
report.txt: an international ring of Foobar bootleggers
address.
txt: Foobar Leitner, Cambridge MA address.
txt: Foobar Industries, North Pole
homework.py: String filename = “Foobar.fum”
Note that the special word being search for is always the
first command line argument.
file names on the command line. Then for each file specified by
each filename, print out every line that contains the keyword --
following the format shown below.
E.g.,
% python find.py Foobar report.txt address.txt
homework.py
might result in the following output:
report.txt: an international ring of Foobar bootleggers
address.
txt: Foobar Leitner, Cambridge MA address.
txt: Foobar Industries, North Pole
homework.py: String filename = “Foobar.fum”
Note that the special word being search for is always the
first command line argument.