Which option prints lines that do not match the given pattern?

Prepare for the Red Hat Certified Systems Admin Exam EX200. Enhance your skills with interactive quizzes, flashcards, and detailed explanations. Ace your certification exam today!

Multiple Choice

Which option prints lines that do not match the given pattern?

Explanation:
To print lines that do not match a given pattern, you use the invert-match option of grep. Grep normally shows lines that contain the pattern you specify; the invert flag flips this behavior, so it outputs only the lines where the pattern does not occur. For example, grep -v 'error' file prints all lines that do not contain the word error. The other flags in the options change how matches are found but don’t invert the result: one adds line numbers to matching lines, another makes the search case-insensitive, and another enables extended regular expressions. So the feature that selects non-matching lines is the invert-match option.

To print lines that do not match a given pattern, you use the invert-match option of grep. Grep normally shows lines that contain the pattern you specify; the invert flag flips this behavior, so it outputs only the lines where the pattern does not occur. For example, grep -v 'error' file prints all lines that do not contain the word error. The other flags in the options change how matches are found but don’t invert the result: one adds line numbers to matching lines, another makes the search case-insensitive, and another enables extended regular expressions. So the feature that selects non-matching lines is the invert-match option.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy