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.
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)- A7% (2)
- B86% (24)
- C4% (1)
- D4% (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.
Color highlighting of matched text is controlled by the --color option, not -v.
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.
Version information is displayed using the --version flag, not -v.
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
Community Discussion
No community discussion yet for this question.