Bird
0
0

Find the issue in this PowerShell on Linux command:

medium📝 Debug Q7 of 15
PowerShell - Cross-Platform PowerShell
Find the issue in this PowerShell on Linux command:
Get-ChildItem -Path /etc | Where-Object { $_.Length -gt 1000 }
AWhere-Object syntax is incorrect; should use -Filter instead
BPipe operator '|' is invalid in PowerShell on Linux
CGet-ChildItem cannot list /etc on Linux
DLength property may not exist on directories, causing errors
Step-by-Step Solution
Solution:
  1. Step 1: Understand properties of items from Get-ChildItem

    Files have Length property (size), but directories do not, which can cause errors in filtering.
  2. Step 2: Analyze filtering with Where-Object

    Filtering on Length without checking item type may cause runtime errors or unexpected results.
  3. Final Answer:

    Length property may not exist on directories, causing errors -> Option D
  4. Quick Check:

    Directories lack Length property [OK]
Quick Trick: Check item type before filtering on Length property [OK]
Common Mistakes:
  • Assuming all items have Length property
  • Misusing -Filter parameter instead of Where-Object
  • Thinking pipe operator is invalid on Linux PowerShell

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes