I am trying to parse a log file to extract userIds. Below is how each log is setup in catalina.out. I want to extract just the userId. How would I do that. I tried awk and grep but it returns the entire block instead of just userId. Also, I want to get every unique userId once, because the same user could log in multiple times obviously so I just want the file I write it to to just have it once. Could you guys please help me get an idea where to start? Thanks!
Here are the commands I've tried:
awk '/userId/' catalina.out
grep "userId" catalina.out
When I do this instead of returning back the userId, it returns back the entire block (as seen below)
Log format:
03:44:04.373 [127.0.0.1-8009-exec-178]
INFO c.c.c.x.x.w.f.AuthenticationFilter - cachObj
{"guid":"guid","userId":"userId","isPrimary":false,"accessToken":"accessToken"}
I am assuming your userids will be found like "userId":"test_chumma" etc etc, if this is the case then following may help you in same.
Off course if you have more requirements then kindly show us more sample output with full conditions.