0
0
Linux CLIscripting~10 mins

grep (search text patterns) 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 the word 'error' in the file 'log.txt'.

Linux CLI
grep [1] log.txt
Drag options to blanks, or click blank then click option'
A-v
B-i
C"error"
D-r
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.
2fill in blank
medium

Complete 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'
A-v
B-i
C-r
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v which inverts the match.
Using -r which searches recursively.
3fill in blank
hard

Fix 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'
A-c
B-i
C-v
D-n
Attempts:
3 left
💡 Hint
Common Mistakes
Using -i which ignores case but does not count.
Using -v which inverts the match.
4fill in blank
hard

Fill 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'
A-r
B-i
C-n
D-v
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v which excludes matches.
Using -i which ignores case but is not needed here.
5fill in blank
hard

Fill 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'
A-i
B-c
C-l
D-n
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up -c and -l options.
Forgetting to use -i for case-insensitive search.