LPIC-1 Shells, Scripting and Data Management Practice Question
A directory contains files with spaces and special characters in their names. An administrator wants to delete all files older than 30 days using find and xargs. Which command is safe?
⚠ Common exam trap
A common mix-up: candidates choose option C, overlooking the fact that default xargs splits on whitespace and interprets quotes, making it unsafe for filenames with spaces or special characters, while `-print0` and `-0` are the correct safe approach.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
find /path -type f -mtime +30 -print0 | xargs -0 rm
It uses `-print0` with `find` to output null-delimited filenames, and `xargs -0` to process them safely. This handles spaces, newlines, and special characters in filenames without word-splitting or shell interpretation, ensuring all matching files older than 30 days are deleted reliably.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
find /path -type f -mtime +30 -delete
Why it's wrong here
Safe and efficient but does not use xargs.
- ✗
find /path -type f -mtime +30 -exec rm {} \;
Why it's wrong here
Safe but does not use xargs, and is less efficient for many files.
- ✗
find /path -type f -mtime +30 | xargs rm
Why it's wrong here
Does not handle spaces or special characters; xargs may break filenames.
- ✓
find /path -type f -mtime +30 -print0 | xargs -0 rm
Why this is correct
Uses null delimiter to safely handle any filename.
Go deeper
Related to this question
About these practice questions
One of 527 original LPIC-1 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LPIC-1 practice question is part of Courseiva's free LPI certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LPIC-1 exam.