LPIC-1 Shells, Scripting and Data Management Practice Question
An administrator wants to list all lines in a log file that do NOT contain the word 'ERROR'. Which command should be used?
⚠ Common exam trap
Watch out — candidates often confuse the `-v` invert-match flag with other common flags like `-i` (case-insensitive) or `-w` (whole-word), or simply forget that `grep` by default shows matching lines, not excluding them.
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
✓
grep -v 'ERROR' logfile
The `-v` flag inverts the match, causing `grep` to output only lines that do NOT contain the pattern 'ERROR'. This is the standard way to exclude lines matching a pattern in a file.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
grep -i 'ERROR' logfile
Why it's wrong here
This case-insensitively matches lines containing ERROR.
- ✗
grep -w 'ERROR' logfile
Why it's wrong here
This matches whole words only, still showing lines containing ERROR.
- ✓
grep -v 'ERROR' logfile
Why this is correct
The -v option inverts the match.
- ✗
grep 'ERROR' logfile
Why it's wrong here
This shows lines containing ERROR.
Go deeper
Related to this question
About these practice questions
This LPIC-1 question is part of Courseiva's 527-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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.