0
0
Linux CLIscripting~10 mins

grep with regex (-E) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A-i
B-c
C-v
D-E
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.
2fill in blank
medium

Complete 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'
A-c
B-v
C-E
D-i
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.
3fill in blank
hard

Fix 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'
A|
B*
C.
D+
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.
4fill in blank
hard

Fill 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'
A-E
B-i
C-v
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v which inverts the match.
Using -c which counts matches instead of showing them.
5fill in blank
hard

Fill 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'
A-E
B-i
C-v
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up -v and -c options.
Forgetting to use -E for extended regex (though not asked here).