Which command would search for the string 'error' in all log files under /var/log and show matching lines with context?

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 would search for the string 'error' in all log files under /var/log and show matching lines with context?

Explanation:
The main idea is to find every occurrence of a text string across a directory tree and show exactly where each match appears. Using recursive search lets you scan every file under /var/log, not just the top-level directory. Printing line numbers alongside matches helps you locate the exact position of each hit within the files. Making the search case-insensitive ensures you catch variations like Error, ERROR, or error, so nothing is missed due to capitalization. The command targets the literal string "error" and will report every line that contains it, across all log files in /var/log, with the file path and line number included. If you truly want surrounding lines for additional context, you’d add a context option (like -C), but the given command already provides the location of each match and the exact line containing it.

The main idea is to find every occurrence of a text string across a directory tree and show exactly where each match appears. Using recursive search lets you scan every file under /var/log, not just the top-level directory. Printing line numbers alongside matches helps you locate the exact position of each hit within the files. Making the search case-insensitive ensures you catch variations like Error, ERROR, or error, so nothing is missed due to capitalization. The command targets the literal string "error" and will report every line that contains it, across all log files in /var/log, with the file path and line number included. If you truly want surrounding lines for additional context, you’d add a context option (like -C), but the given command already provides the location of each match and the exact line containing it.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy