AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Grep unique reads9/3/2023 ![]() Moreover, we can define an action to perform whenever a match is found. It lets us write small but effective programs as statements that define text patterns to search for. ![]() The awk command is a Linux utility to manipulate data and generate reports based on the data. We’re passing the -c option to the uniq command to get the total count of individual IP addresses. It also filters the list so it’ll only print unique IP addresses and their respective counts: $ grep -Eo '(25|2|?)\.(25|2|?)\.(25|2|?)\.(25|2|?)' sample.log | uniq -c | sort This counts and sorts the records in ascending order. We can push things further and pipe the results to the uniq and sort commands. We’re using the -E option to interpret the patterns as extended regular expressions (EREs) and the -o option to trim the results and only print the matched part. ![]() This regular expression is more strict since it only matches IP addresses that have a value equal to or less than 255 in each of its four parts. ![]() In the next sections, we’ll explore different methods for extracting IP addresses from this file. NET CLR )" "-"ħ3.166.162.225 - "GET /apache-log/access.log HTTP/1.1" 200 1299 "-" "Mozilla/5.0 (Windows NT 10.0 Win64 圆4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/.101 Safari/537.36" "-"Įach line above represents different entries in this format: IP-ADDRESS - REQUEST & REQUEST-INFORMATION ![]()
0 Comments
Read More
Leave a Reply. |