

The cut command there simply throws away all the output except for the first field on each line, which is the IP address. Ask Question Asked 9 years, 6 months ago.

access.log) using a recursive option (often -r). One quick way to see which IP addresses are most active is to sort by them: cat access.log cut -d -f 1 sort. Counting number of times each IP address appears in log file. Search against all the files (use wildcards if needed - i.e.

Use a command to extract IP addresses - look online to get a regex here and understand the parameters of the different binaries you can use. which finds the lines via grep, uses cut to extract the first field (space delimited), sorts the IP addresses and then uniq. For this last task, I did this: less file name | grep -c "404"īut still I need to make a list of those response code.
#Apache log grep unique ip code
Then, I need to show how many times each response code is repeated. I need to make a list of the codes use, for example, 400, 200, 304, 404. Step 2: Display a Specific Term from Access Logs Sometimes, you only want to display a specific type of entry in the log. I was given a log file which contains some response codes (actually they are too many). If your log file is in a different place, make sure to substitute your machine’s path to the Apache log files.
