
Your sample IP address made eight requests. If you’re looking for a count, pipe the results through the word count utility, *wc*. So, now you see each time that a specific IP address accessed this server. You got a much smaller result set now because *^* means match the following string only if it occurs at the beginning of the line. What if you only want to see requests? Try pasting in a regular expression that matches a line beginning with 46.72.177.4. That indicates an HTTP request from that address. Some of the lines start with the IP address you’re looking for. It found all of the instances of 46.72.177.4 in the file and returned the lines that contain it.


Grep did exactly what you asked it to do. I trimmed the results from the sample file to save room. Run grep with the IP address you’re looking for and the name of the log file. Grep for an Exact IP Address in a Log Fileįirst, let’s take a look at searching for an exact address in an access log.
