Trying to cram all of the following into the title was hard, so this is what I really mean:
I am doing a
tail -F access.log to watch an Apache2 log in realtime. The first thing on each line is an IP address followed by a space. I also have an unchanging CSV file where each row is an IP address, comma, name. For example:
Deliverable: I want to follow my access log as before, but if the CSV happens to contain a row with the same IP address that the current logfile line starts with, then insert the person's name at the start of the line.
For example, a line like this:
10.1.2.33 - - [22/Aug/2013:13:41:24 +0000] "GET /index.php ...
Should instead render as:
John Smith 10.1.2.33 - - [22/Aug/2013:13:41:24 +0000] "GET /index.php ...
Ideally, I would like to do this entirely by piping some regex commands together. So far, my biggest issue is that grep doesn't accept a pattern on stdin, it expects the subject on stdin (unless I'm missing something). Also, I have no problem transforming the CSV into some better format if required. Thanks.