AnotherAlan
Technical User
Should be simple, but haven't used awk in a while and am currently snowbound in the uk, so trying to do this from a cygwin emulation on a dodgy laptop; however, i'm sure i'm making it more difficult than it needs be.
Problem: Retrieve data from log file based on two parameters;The order and matching pattern.
So, in the below, the order 1290119786 will give me the pattern to search on [103].
[2010-11-19 15:42:40.313 INFO] Logfile [103] Creating update order 1290119786
I can do this with a couple of greps, but was attempting something with awk because I thought it would be faster; as the log files can be huge.
num=`grep <order number> logfile | awk '{print $5}'| uniq`
awk -v num=$num '$5=="["num"]" {print $0}' testfile.log
this gets me close, although I would still need to strip out the [ and ]'s from the original grep to get the num variable. My real issue therefore is to get awk to accept [103] as a string comparison in $5, but all iterations i've tried just don't seem to work. Now i'm not sure if this is a cygwin quoting interpretation or just my rusty old awk / brain.
All help appreciated.
Thanks
Problem: Retrieve data from log file based on two parameters;The order and matching pattern.
So, in the below, the order 1290119786 will give me the pattern to search on [103].
[2010-11-19 15:42:40.313 INFO] Logfile [103] Creating update order 1290119786
I can do this with a couple of greps, but was attempting something with awk because I thought it would be faster; as the log files can be huge.
num=`grep <order number> logfile | awk '{print $5}'| uniq`
awk -v num=$num '$5=="["num"]" {print $0}' testfile.log
this gets me close, although I would still need to strip out the [ and ]'s from the original grep to get the num variable. My real issue therefore is to get awk to accept [103] as a string comparison in $5, but all iterations i've tried just don't seem to work. Now i'm not sure if this is a cygwin quoting interpretation or just my rusty old awk / brain.
All help appreciated.
Thanks