Challenge - 5 Problems
Shell Scripting Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
PowerShell vs Bash: Command Output Differences
What is the output of this PowerShell command compared to its Bash equivalent?
PowerShell:
Bash:
Assuming both commands run in a directory with files of various sizes, what does the PowerShell command output?
PowerShell:
Get-ChildItem | Where-Object { $_.Length -gt 1000 }Bash:
ls -l | awk '$5 > 1000'Assuming both commands run in a directory with files of various sizes, what does the PowerShell command output?
PowerShell
Get-ChildItem | Where-Object { $_.Length -gt 1000 }Attempts:
2 left
💡 Hint
Think about how PowerShell objects have properties like Length and how Where-Object filters them.
✗ Incorrect
PowerShell's Get-ChildItem returns objects with properties like Length for files. The Where-Object filters those with Length greater than 1000 bytes, listing files (and directories if they have Length).
📝 Syntax
intermediate1:30remaining
Syntax Differences: Variable Assignment
Which of the following is the correct way to assign a variable in PowerShell compared to Bash and CMD?
Attempts:
2 left
💡 Hint
PowerShell uses $ before variable names.
✗ Incorrect
PowerShell requires $ before variable names for assignment. Bash uses var= without spaces, CMD uses set var=, and let is not used for assignment in these shells.
🔧 Debug
advanced2:00remaining
Debugging a PowerShell Pipeline vs Bash Pipeline
Given this PowerShell pipeline:
and this Bash pipeline:
Which statement about their behavior is true?
Get-Process | Where-Object { $_.CPU -gt 100 }and this Bash pipeline:
ps aux | awk '$3 > 100'Which statement about their behavior is true?
Attempts:
2 left
💡 Hint
Consider what the CPU property in PowerShell and the third column in ps aux represent.
✗ Incorrect
PowerShell's CPU property is total CPU time in seconds, so filtering >100 means processes running more than 100 seconds CPU time. Bash's ps aux third column is CPU usage percentage, so >100% is unusual but possible on multi-core systems.
🚀 Application
advanced2:30remaining
Automating File Backup: PowerShell vs CMD
You want to copy all .txt files from C:\Data to D:\Backup preserving directory structure.
Which PowerShell command correctly does this compared to CMD's
Which PowerShell command correctly does this compared to CMD's
xcopy C:\Data D:\Backup /S /I /Y?Attempts:
2 left
💡 Hint
Preserving directory structure requires the -Container parameter in PowerShell.
✗ Incorrect
The -Container parameter preserves the directory structure when copying recursively. Without it, only files are copied without folders.
🧠 Conceptual
expert3:00remaining
Understanding Object vs Text Pipelines
PowerShell pipelines pass objects between commands, while Bash and CMD pipelines pass text streams.
What is a key advantage of PowerShell's object pipeline over text pipelines?
What is a key advantage of PowerShell's object pipeline over text pipelines?
Attempts:
2 left
💡 Hint
Think about how objects carry structured data compared to plain text.
✗ Incorrect
PowerShell's object pipeline passes rich data with properties and methods, allowing commands to manipulate data precisely without parsing text, unlike Bash or CMD which pass plain text streams.