Which command pattern would select lines that do not start with the letters l, i, n, u, or x?

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 command pattern would select lines that do not start with the letters l, i, n, u, or x?

Explanation:
This tests how to exclude lines based on their first character using a regular expression with grep. The caret anchors the match to the start of the line, and a character class like [linux] means “any one of these letters.” So ^[linux] matches lines whose very first character is one of l, i, n, u, or x. Adding -v inverts the match, so grep -v '^[linux]' prints only lines whose first character is not any of those letters. That directly expresses “lines that do not start with the letters l, i, n, u, or x.” Lines starting with any of those five letters will be omitted, while lines beginning with any other character will be included. Other patterns shift away from this exact intent: without inversion, it would choose lines that do start with those letters; negating a character class without anchoring to the start would affect matches inside the line rather than at the beginning; and including -n only adds line numbers to output, not change which lines are selected.

This tests how to exclude lines based on their first character using a regular expression with grep. The caret anchors the match to the start of the line, and a character class like [linux] means “any one of these letters.” So ^[linux] matches lines whose very first character is one of l, i, n, u, or x. Adding -v inverts the match, so grep -v '^[linux]' prints only lines whose first character is not any of those letters. That directly expresses “lines that do not start with the letters l, i, n, u, or x.”

Lines starting with any of those five letters will be omitted, while lines beginning with any other character will be included.

Other patterns shift away from this exact intent: without inversion, it would choose lines that do start with those letters; negating a character class without anchoring to the start would affect matches inside the line rather than at the beginning; and including -n only adds line numbers to output, not change which lines are selected.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy