turtle
2012-11-17, 13:42
So I'm trying to run a one-liner that will parse a stack of log files and then give me a nice trimmed set of results. I'm getting stuck at one point because there is a pattern I want to use but can't seem to find the syntax to use it. My preference is to use awk. Here is what I currently have:
# cat status.log*|grep "activated"|sort
Which gives a result of:
2012-11-17 12:17:45 [STATUS] turtle [/192.168.x.x:60172] activated
There are more lines than this, but this is the example I need. What I want to do is sed out that "[STATUS]" and then cut off the IP so I output would be date time and username like this:
2012-11-17 12:17:45 turtle
If we go that route then I would remove the leading "[" and be able to use it in my awk statement and be just fine. I would just awk -F [ {' print $1 '} or use cut and have the results I want.
Minimally I would like to use the "[/" as the awk point and use something like awk -F [/ {' print $1 '}. This only results in failure though. :(
awk: fatal: Unmatched [ or [^: /[//
So how about some unix guys helping a budding admin out? Man pages are looking like Chinese to me at this point.
# cat status.log*|grep "activated"|sort
Which gives a result of:
2012-11-17 12:17:45 [STATUS] turtle [/192.168.x.x:60172] activated
There are more lines than this, but this is the example I need. What I want to do is sed out that "[STATUS]" and then cut off the IP so I output would be date time and username like this:
2012-11-17 12:17:45 turtle
If we go that route then I would remove the leading "[" and be able to use it in my awk statement and be just fine. I would just awk -F [ {' print $1 '} or use cut and have the results I want.
Minimally I would like to use the "[/" as the awk point and use something like awk -F [/ {' print $1 '}. This only results in failure though. :(
awk: fatal: Unmatched [ or [^: /[//
So how about some unix guys helping a budding admin out? Man pages are looking like Chinese to me at this point.