header bg

Scan QR code or get instant email to install app

Question:

Bill wishes to determine the number of times an event occurred and plans to examine a log file containing the event. If each instance of the event is logged individually in the logfile.txt log file utilizing a unique event ID (event101), which grep command among the options would inform him about the count of the event's occurrences?

A grep -c 'event101' logfile.txt.
explanation

The -c flag in grep is used to tally the number of instances of a specific string in a file. The -n flag displays the matching lines along with their line numbers. Even if one is unsure about the flag options, the syntax can be helpful in answering such questions. In grep, the pattern is entered prior to the filename, enabling the exclusion of two of the options right away.

Related Information

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*