Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to search for the word 'error' in the file 'log.txt'.
PowerShell
Select-String -Path 'log.txt' -Pattern [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a pattern that does not match the search word.
Forgetting to put the pattern in quotes.
✗ Incorrect
The pattern to search for is 'error', so the correct option is 'error'.
2fill in blank
mediumComplete the code to search for the word 'fail' in all '.log' files in the current folder.
PowerShell
Select-String -Path [1] -Pattern 'fail'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong file extension in the path.
Not using quotes around the path pattern.
✗ Incorrect
To search all '.log' files, use the wildcard '*.log' as the path.
3fill in blank
hardFix the error in the code to search for the word 'success' in 'output.txt'.
PowerShell
Select-String -Path 'output.txt' -Pattern [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the pattern string.
Using incorrect capitalization if case sensitivity matters.
✗ Incorrect
The pattern must be a string enclosed in quotes. Using 'success' with quotes is correct.
4fill in blank
hardFill both blanks to search for the word 'warning' in all '.txt' files and ignore case.
PowerShell
Select-String -Path [1] -Pattern [2] -CaseSensitive $false
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong file extension in the path.
Using a pattern with uppercase when ignoring case.
✗ Incorrect
Use '*.txt' to select text files and 'warning' as the pattern to search ignoring case.
5fill in blank
hardFill all three blanks to search for the word 'error' in 'app.log' and show only the line numbers.
PowerShell
Select-String -Path [1] -Pattern [2] | Select-Object [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting the wrong property like Line instead of LineNumber.
Forgetting quotes around file name or pattern.
✗ Incorrect
Use 'app.log' as the file, 'error' as the pattern, and select the LineNumber property to show line numbers.