LFCS · Question #797
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. When the -v option is used with the egrep command, it performs an inverse match, showing only lines that do not contain the specified pattern.
Question
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
(45 responses)- B93% (42)
- C4% (2)
- D2% (1)
Why each option
When the `-v` option is used with the `egrep` command, it performs an inverse match, showing only lines that do not contain the specified pattern.
Enabling color highlighting is typically done with options like `--color` or through shell configuration, not `-v`.
The `-v` (or `--invert-match`) option with `egrep` (and `grep`) modifies its behavior to output only those lines from the input that do *not* match the provided regular expression pattern.
Displaying version information for a command is usually achieved with `--version` or `-V`, not `-v`.
The `-v` option filters lines based on whether they match a pattern; it does not alter the order of the output.
Concept tested: egrep -v option (invert match)
Source: https://www.gnu.org/software/grep/manual/grep.html
Topics
Community Discussion
No community discussion yet for this question.