Recall & Review
beginner
What does the
-E option do in the grep command?The
-E option tells grep to use extended regular expressions, allowing more powerful pattern matching like +, ?, | without escaping.Click to reveal answer
beginner
Which symbol in extended regex means 'one or more' of the previous character or group?
The
+ symbol means 'one or more' of the previous character or group in extended regex.Click to reveal answer
beginner
How do you search for lines containing either 'cat' or 'dog' using
grep -E?Use the pattern
cat|dog with grep -E. For example: grep -E 'cat|dog' filename finds lines with 'cat' or 'dog'.Click to reveal answer
intermediate
What is the difference between
grep and grep -E?grep uses basic regular expressions where some symbols like +, ?, | need escaping. grep -E uses extended regex where these symbols work directly.Click to reveal answer
intermediate
Write a
grep -E command to find lines with a digit repeated 3 times in a row.Use the pattern
[0-9]{3} with grep -E. Example: grep -E '[0-9]{3}' filename finds lines with three digits in a row.Click to reveal answer
What does the pattern
a+b match in grep -E?✗ Incorrect
In extended regex, '+' means one or more of the previous character. So
a+b matches one or more 'a' followed by 'b'.Which command uses extended regex to find lines with 'cat' or 'dog'?
✗ Incorrect
grep -E enables extended regex, so the '|' operator works as OR.In
grep -E, what does ? mean?✗ Incorrect
The '?' quantifier means zero or one occurrence of the previous character or group.
How do you match exactly 4 digits in a row using
grep -E?✗ Incorrect
Curly braces specify exact repetition count.
{4} means exactly 4 times.Which of these is NOT a feature of extended regex in
grep -E?✗ Incorrect
The '\d' shorthand is not supported in basic or extended grep regex; it requires Perl regex or other tools.
Explain how to use
grep -E to search for multiple patterns with OR logic.Think about how extended regex lets you use | without escaping.
You got /4 concepts.
Describe the main quantifiers available in extended regex and how they change pattern matching.
Quantifiers control how many times a character or group repeats.
You got /6 concepts.