Bird
0
0

Which of the following is the correct syntax to delete a file named log.txt using Remove-Item?

easy📝 Syntax Q3 of 15
PowerShell - File and Directory Operations
Which of the following is the correct syntax to delete a file named log.txt using Remove-Item?
ARemove-Item /log.txt
BRemove-Item log.txt -Path
CRemove-Item -Path log.txt
DRemove-Item --file log.txt
Step-by-Step Solution
Solution:
  1. Step 1: Check correct parameter usage

    -Path specifies the file or folder to delete. It should come before the file name.
  2. Step 2: Validate syntax correctness

    Remove-Item -Path log.txt uses Remove-Item -Path log.txt, which is correct syntax. Others misuse parameters or use invalid flags.
  3. Final Answer:

    Remove-Item -Path log.txt -> Option C
  4. Quick Check:

    Correct Remove-Item syntax = Remove-Item -Path filename [OK]
Quick Trick: Use -Path before the file or folder name [OK]
Common Mistakes:
  • Placing -Path after filename
  • Using Unix-style slashes
  • Using unsupported flags like --file

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes