So I have a log running in real time and saving to a text file named 'test.txt' also in real time. Now I want to set up a process that constantly polls that text file for changes and cuts out a specific reoccuring bit of data. For example the log looks like:
Feb 9 11:43:24 dnsmasq: query[A] captive.g.aaplimg.com from 192.168.178.21 Feb 9 11:43:24 dnsmasq: forwarded captive.g.aaplimg.com to 126.96.36.199 Feb 9 11:43:24 dnsmasq: reply captive.g.aaplimg.com is 188.8.131.52 Feb 9 11:43:24 dnsmasq: reply captive.g.aaplimg.com is 184.108.40.206 Feb 9 11:43:54 dnsmasq: query[A] captive.g.aaplimg.com from 192.168.178.21
And i want to cut info from only the lines with query[A] so that the output text looks like:
But the problem is that there are different URL's attached to this line of the log, so for example it could look like:
Feb 9 11:49:56 dnsmasq: query[A] www.googleapis.com from 192.168.178.21
Then I would want the output to be:
But it needs to happen in real-time, as the text file/log is updating.
Running on debian buster on pi.