Linux Foundation Certified System Administrator Exam - Effect of egrep Command with -v Option

Effect of the egrep Command with -v Option

Question

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

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B

The egrep command is used to search for patterns in text files using regular expressions. When the -v option is used with egrep, it means to output only those lines that do not match the given pattern.

For example, suppose you have a file called sample.txt that contains the following lines:

apple banana orange grape

If you run the following command:

python
egrep -v "an" sample.txt

The output will be:

apple grape

Because the lines containing "an" (i.e., "banana" and "orange") are excluded from the output.

Option A is incorrect because the -v option does not affect color highlighting. Option C is incorrect because the -v option does not show the command's version information. Option D is incorrect because the -v option does not change the order of the output.

Therefore, the correct answer is B: the -v option only outputs non-matching lines.