March 2018
Beginner to intermediate
416 pages
9h 24m
English
AWK is used here to split the lines of the log file into fields or columns, using a default separator. Since each line in an Apache log file follows a standard format, we can process it easily with AWK. We will be using a default separator (spaces or tabs) to parse the log file sample line used previously, as follows:
$ vi sample.txt83.149.9.216 - - [17/Feb/2018:10:05:03 +0000] "GET /presentations/images/search.png HTTP/1.1" 200 203023 "http://semicomplete.com/presentations/2013/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36"
$ awk '{print $1}' sample.txt
$ awk ...
Read now
Unlock full access