Bird
0
0

You want to delete all files with extension .tmp inside /var/logs and its subdirectories safely. Which command is best?

hard📝 Application Q8 of 15
Linux CLI - File and Directory Operations
You want to delete all files with extension .tmp inside /var/logs and its subdirectories safely. Which command is best?
Afind /var/logs -type f -name '*.tmp' -exec rm -i {} +
Brm -i /var/logs/*.tmp
Crm -rf /var/logs/*.tmp
Drm -r /var/logs/*.tmp
Step-by-Step Solution
Solution:
  1. Step 1: Understand the need to delete recursively and safely

    Files may be in subdirectories, so recursive search is needed, and safe deletion means prompting. Analyze options: find /var/logs -type f -name '*.tmp' -exec rm -i {} + uses find to locate all .tmp files recursively and deletes them interactively.
  2. Final Answer:

    find /var/logs -type f -name '*.tmp' -exec rm -i {} + -> Option A
  3. Quick Check:

    Use find with rm -i for safe recursive deletion [OK]
Quick Trick: Use find with rm -i for safe recursive deletes [OK]
Common Mistakes:
  • Using rm with wildcard only deletes top-level files
  • Forgetting to prompt before delete
  • Using -r on files only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes