Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to search for the word 'error' in the file 'log.txt'.
Bash Scripting
grep [1] log.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -v option which inverts the match.
Using -i which ignores case, but the task wants exact match.
✗ Incorrect
The command grep 'error' log.txt searches for the exact word 'error' in the file.
2fill in blank
mediumComplete the code to search for lines starting with 'Error' in 'log.txt'.
Bash Scripting
grep [1] log.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Error$' which matches lines ending with 'Error'.
Not using ^ so matches anywhere in the line.
✗ Incorrect
The caret ^ means the line starts with the pattern 'Error'.
3fill in blank
hardFix the error in the code to search for lines containing digits in 'data.txt'.
Bash Scripting
grep [1] data.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '\d' which is not recognized by basic grep.
Using character classes that do not include digits.
✗ Incorrect
The pattern '[0-9]' matches any digit. '\d' is not supported by basic grep regex.
4fill in blank
hardFill both blanks to create a grep command that finds lines with exactly three digits in a row in 'file.txt'.
Bash Scripting
grep [1][2] file.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '\{2\}' which matches two digits instead of three.
Using '[a-z]' which matches letters, not digits.
✗ Incorrect
The pattern '[0-9]\{3\}' matches exactly three digits in a row in basic grep regex.
5fill in blank
hardFill all three blanks to create a grep command that finds lines starting with 'ID' followed by one or more digits in 'records.txt'.
Bash Scripting
grep [1][2][3] records.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '\+' which is not supported in basic grep regex.
Not anchoring the pattern with '^' to match start of line.
✗ Incorrect
The pattern '^ID[0-9]\{1,\}' matches lines starting with 'ID' followed by one or more digits in basic grep regex.