1. Home
  2. Docs
  3. Beginning UNIX on Raven
  4. Answers
  5. Answers to exercises using grep

Answers to exercises using grep

1. How many times does the jester appear in our lyrics?

Answer: 3

Command: grep jester americanpie.txt

2. How many times does Jack appear at the start of a line?

Answer: 1

Command: grep ^Jack americanpie.txt

3. What would this command look like you made it case insensitive?

grep –i ^Jack americanpie.txt

4. How many times does dance end at the end of a line?

Answer: 2

Command: grep dance$ americanpie.txt

5. Combining two grep searches how many times were ‘we’ singing ‘bye-bye’ to Miss American Pie?

Answer: 2

Command: grep bye-bye americanpie.txt | grep ^We

6. How many times were people saying bye-bye?

Answer: 7

Command: grep bye-bye americanpie.txt