LPIC-1 Shells, Scripting and Data Management Practice Question
A system administrator is tasked with migrating several shell scripts from a legacy UNIX system to a new Linux server. One script uses the command 'grep -E "pattern1|pattern2"' which works fine on the old system. However, on the new Linux server, the patterns are not being matched correctly. The administrator suspects it is due to differences in grep implementations. Which of the following is the most likely reason for the discrepancy?
⚠ Common exam trap
It's easy for candidates to assume all Linux systems use GNU grep and that the -E flag is universally supported, overlooking the existence of BusyBox grep in lightweight distributions, which lacks the -E flag entirely.
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
✓
The new system's grep does not support the -E flag (e.g., BusyBox grep).
BusyBox grep, commonly found in embedded or minimal Linux environments, does not support the -E flag for extended regular expressions. The script uses 'grep -E' with alternation (|), which is an extended regex feature. If the new system runs BusyBox grep, the -E flag is unrecognized, causing grep to interpret the pattern as a basic regex where '|' is treated as a literal character, not an alternation operator, leading to failed matches.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The old system used GNU grep and the new system uses BSD grep, which treats the -E flag the same.
Why it's wrong here
Both support -E; no discrepancy.
- ✗
The old system's grep interpreted the pattern as basic regex and the new system's grep interprets it as extended regex because of the -E flag, but the pattern syntax is the same.
Why it's wrong here
The -E flag explicitly enables extended regex on both; no difference.
- ✗
The pattern includes metacharacters that are interpreted differently because the shell's locale settings are different.
Why it's wrong here
Locale affects character classes, not alternation.
- ✓
The new system's grep does not support the -E flag (e.g., BusyBox grep).
Why this is correct
BusyBox grep may not include -E; it only supports basic regular expressions.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LPIC-1 question from scratch — 527 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.