Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to search for the word 'error' in the file 'log.txt'.
Linux CLI
grep [1] log.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using options like -i or -v instead of the search pattern.
Forgetting to put the search word in quotes.
✗ Incorrect
The correct syntax to search for the word 'error' is to put it in quotes after grep.
2fill in blank
mediumComplete the code to search for the word 'Warning' in 'system.log' ignoring case.
Linux CLI
grep [1] "Warning" system.log
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v which inverts the match.
Using -r which searches recursively.
✗ Incorrect
The -i option makes grep ignore case when searching.
3fill in blank
hardFix the error in the command to count lines containing 'fail' in 'report.txt'.
Linux CLI
grep [1] fail report.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -i which ignores case but does not count.
Using -v which inverts the match.
✗ Incorrect
The -c option counts the number of matching lines.
4fill in blank
hardFill both blanks to search recursively for 'TODO' in all files and show line numbers.
Linux CLI
grep [1] [2] TODO .
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v which excludes matches.
Using -i which ignores case but is not needed here.
✗ Incorrect
Use -r to search recursively and -n to show line numbers.
5fill in blank
hardFill all three blanks to search case-insensitively for 'error', count matches, and show filenames only.
Linux CLI
grep [1] [2] [3] error /var/logs/*.log
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up -c and -l options.
Forgetting to use -i for case-insensitive search.
✗ Incorrect
Use -i for case-insensitive, -c to count matches, and -l to show filenames only.