This lesson is based on the Unix Lesson “Finding Things”.
Consider the following text placed in a file called hockey.txt :
Back-to-Back Stanley Cup Winners since 1980:
New York Islanders 1980, 1981, 1982, 1983
Edmonton Oilers 1984, 1985
Edmonton Oilers 1987, 1988
Pittsburgh Penguins 1991, 1992
Detroit Red Wings 1997, 1998
Q1. Which grep command will not return a match?
- grep -i ‘rEd wINGs’ hockey.txt
- grep -v ‘Maple Leafs’ hockey.txt
- grep -n ‘Oil’ hockey.txt
- grep -w ‘Oil’ hockey.txt
Q2. Which grep command will return only the first line?
- grep ‘1980’ hockey.txt
- grep -v ‘Back-to-Back’ hockey.txt
- grep ‘stanley cup’ hockey.txt
- grep -v ‘, ‘ hockey.txt
Answers:
- The pattern 1980 is matched on both lines one and two
- Student does not recognize that -v inverts the match
- Student incorrectly assumes case insensitivity
- Correct Answer