Bird
0
0

You want to remove all empty directories inside ~/projects but keep files. Which command is correct?

hard📝 Application Q9 of 15
Linux CLI - File and Directory Operations
You want to remove all empty directories inside ~/projects but keep files. Which command is correct?
Arm -r ~/projects
Bfind ~/projects -type d -empty -delete
Crm -rf ~/projects/*
Drm -i ~/projects/*
Step-by-Step Solution
Solution:
  1. Step 1: Identify requirement to delete only empty directories

    We want to delete empty directories but keep files intact. Analyze commands: find ~/projects -type d -empty -delete uses find to locate empty directories and deletes them safely.
  2. Final Answer:

    find ~/projects -type d -empty -delete -> Option B
  3. Quick Check:

    Use find with -empty and -delete to remove empty dirs [OK]
Quick Trick: Use find -type d -empty -delete to remove empty folders [OK]
Common Mistakes:
  • Using rm -r deletes files too
  • Using -i doesn't filter empty dirs
  • Confusing file and directory deletion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes