I am trying to find an efficient way of searching through a whole set of files in a directory and only looking for a specific string up to the first comma.
Example of the postgres log file:
Apr 27 03:35:18 test postgres: [5-1] user=postgres,db=postgres,app=psqlclient=127.0.0.1 Apr 27 03:35:18 test postgres: [5-2] user=postgres,db=postgres,app=psqlclient=127.0.0.1
I am only interested in the username used in the files. I could use pgbadger and look at it via HTML but would be quite time consuming.
So as an example, I would be able to see just :
As opposed to the whole set of text before and after the user.
However I am looking for any user not specifically postgres.
I have tried using grep on files but I only see results on just user=postgres.
Is there anyway of searching through a set of files for say user= up until the first comma as an example?
Or even search every file and remove anything that is before user= in each row, I could then maybe put into excel to get the result I need.
Any help is much appreciated.