nerdexam
CompTIA

LX0-103 · Question #197

What is the effect of the egrep command when the -v option is used?

The correct answer is B. It only outputs non-matching lines.. The -v option in egrep (and grep) inverts the matching logic, outputting only lines that do NOT match the given pattern.

GNU and Unix Commands

Question

What is the effect of the egrep command when the -v option is used?

Options

  • AIt enables color to highlight matching parts.
  • BIt only outputs non-matching lines.
  • CIt shows the command's version information.
  • DIt changes the output order showing the last matching line first.

How the community answered

(28 responses)
  • A
    7% (2)
  • B
    86% (24)
  • C
    4% (1)
  • D
    4% (1)

Why each option

The -v option in egrep (and grep) inverts the matching logic, outputting only lines that do NOT match the given pattern.

AIt enables color to highlight matching parts.

Color highlighting of matched text is controlled by the --color option, not -v.

BIt only outputs non-matching lines.Correct

The -v flag stands for 'invert match' and causes egrep to suppress all lines that match the pattern, printing only the non-matching lines instead. This is a standard POSIX grep behavior inherited by egrep. It is commonly used to filter out unwanted lines from command output or log files.

CIt shows the command's version information.

Version information is displayed using the --version flag, not -v.

DIt changes the output order showing the last matching line first.

grep and egrep have no option to reverse output order by last match; tools like tac or sort are used for reordering output.

Concept tested: grep -v invert match option

Source: https://www.gnu.org/software/grep/manual/grep.html#index-_002dv

Topics

#egrep#grep -v#text filtering#pattern matching

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice