Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to search for lines containing the word 'error' using extended regex.
Linux CLI
grep [1] 'error' logfile.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -i instead of -E, which only ignores case.
Using -v which inverts the match.
Using -c which counts matches instead of showing them.
✗ Incorrect
The -E option enables extended regular expressions in grep, allowing more complex patterns.
2fill in blank
mediumComplete the code to find lines that start with 'Error' or 'Warning' using extended regex.
Linux CLI
grep [1] '^(Error|Warning)' logfile.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v which inverts the match.
Using -i which ignores case but doesn't enable extended regex.
Using -c which counts matches instead of showing them.
✗ Incorrect
The -E option allows using the alternation (|) in the regex pattern.
3fill in blank
hardFix the error in the code to match lines containing either 'cat' or 'dog' using extended regex.
Linux CLI
grep -E 'cat[1]dog' animals.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which means zero or more of the previous character.
Using '.' which matches any single character.
Using '+' which means one or more of the previous character.
✗ Incorrect
The '|' symbol is used in extended regex to mean 'or' between patterns.
4fill in blank
hardFill both blanks to search for lines containing either 'apple' or 'banana' and ignore case.
Linux CLI
grep [1] [2] '(apple|banana)' fruits.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v which inverts the match.
Using -c which counts matches instead of showing them.
✗ Incorrect
Use -E for extended regex and -i to ignore case when searching.
5fill in blank
hardFill all three blanks to count lines that do NOT contain 'error' or 'fail' using extended regex and ignoring case.
Linux CLI
grep [1] [2] [3] '(error|fail)' logfile.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up -v and -c options.
Forgetting to use -E for extended regex (though not asked here).
✗ Incorrect
Use -c to count, -i to ignore case, and -v to invert match (exclude lines with the pattern).