Courseiva

LPIC-1 Shells, Scripting and Data Management Practice Question

A junior administrator needs to extract only the lines containing the word 'ERROR' from /var/log/syslog, but the log may have inconsistent casing (e.g., 'ERROR', 'Error', 'error'). Which command will print all such lines while ignoring case?

⚠ Common exam trap

The trap here is assuming that grep is case-insensitive by default or that a simple pattern without flags will catch all casings.

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 -i 'ERROR' /var/log/syslog

To extract lines with any casing of 'ERROR', the case-insensitive option -i must be used with grep. This allows matching 'ERROR', 'Error', 'error', etc., in a single command. The other grep invocations either do not ignore case, invert the match, or count lines instead of displaying them, so they fail to meet the scenario's need.

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 -v 'ERROR' /var/log/syslog

    Why it's wrong here

    The -v option inverts the match, printing lines that do NOT contain 'ERROR'. This is the opposite of what is needed; it would exclude the very lines the administrator wants to extract. Additionally, it remains case-sensitive, so it would also exclude only exact uppercase matches, further missing the goal.

  • ✓

    grep -i 'ERROR' /var/log/syslog

    Why this is correct

    The -i option makes grep perform a case-insensitive match, so it will match 'ERROR', 'Error', 'error', and any other casing. This directly satisfies the requirement to catch inconsistent casing without needing multiple patterns or preprocessing. Other options either do not ignore case or misinterpret the pattern.

  • ✗

    grep 'ERROR' /var/log/syslog

    Why it's wrong here

    Without the -i flag, grep performs a case-sensitive match and will only print lines that contain the exact uppercase string 'ERROR'. Lines with 'Error' or 'error' would be missed, so this fails the requirement to handle inconsistent casing. It is the default behavior and not suitable here.

  • ✗

    grep -c 'ERROR' /var/log/syslog

    Why it's wrong here

    The -c option tells grep to count matching lines instead of printing them. The administrator needs to see the actual log entries, not just a count. Also, it is case-sensitive, so it would only count exact uppercase 'ERROR' occurrences, missing other casings. Thus it does not fulfill the extraction requirement.

About these practice questions

This LPIC-1 question is part of Courseiva's 402-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 →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official LPI exam blueprint

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.