These multiple choice questions address the “Finding Things” section in the Unix Shell lesson.
Formative Question
Which command would you use to find a string in any Python file on the file system?
- A. Command including
find
, but withoutgrep
. - B. Command including both
find
andgrep
. - C. Command including
grep -r
, but withoutfind
. - D. Command including
grep -r --include
, but withoutfind
.
Summative Question
Which command would you use to find text files mentioned in text files?
- A.
find . -name "*.txt" | grep .txt
- B.
grep -r .txt
- C.
grep .txt $(find . -name "*.txt")
- D.
grep -w .txt $(find . -name "*.txt")
Explanation
- A. Demonstrates a misunderstanding of the way
grep
interacts with the pipe throughput. This answer greps the output offind
as if it is one file. - B. Demonstrates a misunderstanding of the difference between searching for text in all files and the search for text in a subset of files.
- C. Correct answer.
- D. Demonstrates a misunderstanding of the way
grep
arguments modify the search query.