Selecting entries by date

Having seen how we can display the date, we should perhaps look at how we print entries from just one day. To do this, we can use the match operator in awk. This is denoted by the tilde or squiggly line, if you prefer. As we only need the date element, there is no need for us to use both the date and time zone field. The following command shows how to print entries from September 10, 2014:

$ awk ' ( $4 ~ /10\/Sep\/2014/ ) ' access.log  

For completeness, this command and partial output is shown in the following screenshot:

The round brackets or parentheses embrace the range of lines that we are looking for and we have ...

Get Mastering Linux Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.