Currently I have a file with the format as follows:
####<Oct 23, 2015 10:23:34 AM PDT> <ERROR> <com.foo.biz.jrules.ilog.RulesEngine> <BELC02NF206G3QN> <tcbiz2_1> <siteType=DOMESTIC> <catalina-exec-16> <sessionId=432407E73A6BFE1C4AFE8205ED386907> <clientIp=127.0.0.1> <com.foo.biz.jrules.ilog.RulesEngine.mapPricedSearch(?:?):priceRuleDesc=SNSDTA:PRO-18.612782:NOBTA>
####<Oct 23, 2015 10:23:34 AM PDT> <ERROR> <com.foo.biz.jrules.ilog.RulesEngine> <BELC02NF206G3QN> <tcbiz2_1> <siteType=DOMESTIC> <catalina-exec-16> <sessionId=432407E73A6BFE1C4AFE8205ED386907> <clientIp=127.0.0.1> <com.foo.biz.jrules.ilog.RulesEngine.mapPricedSearch(?:?):priceRuleDesc=SNSDTA:PRO-15.806297:NOBTA>
####<Oct 23, 2015 10:23:34 AM PDT> <ERROR> <com.foo.biz.jrules.ilog.RulesEngine> <BELC02NF206G3QN> <tcbiz2_1> <siteType=DOMESTIC> <catalina-exec-16> <sessionId=432407E73A6BFE1C4AFE8205ED386907> <clientIp=127.0.0.1> <com.foo.biz.jrules.ilog.RulesEngine.mapPricedSearch(?:?):priceRuleDesc=SNSDTA:PRO-4.2497005:NOBTA>
I'm trying to strip out everything after the priceRuleDesc=
term and before the last >
character. Currently, I'm trying to test out a regex in sed on my Mac to accomplish this, but without much luck.
The command I'm using is:
cat ~/myapp/logs/tcbiz2_1.log | grep -i priceRuleDesc | sed -E 's/^.*priceRuleDesc=/foo/'
Surprisingly in my sed command, the ^.*priceRuleDesc=
doesn't doesn't match to substitute everything on the line up until then with foo
. I suspect that the ^.*
is just walking to the end of the line without being smart enough to stop when priceRuleDesc
occurs. I found another question somewhat similar to this one called Non greedy regex matching in Sed, but I'm not convinced that what's going on in that question is what's going on here, and I would also like to know if there is a Sed solution for this. Also, I'm sure that this must be a duplicate of some other question here that I'm just not finding. So if anybody could point me to the right question that would be great, or supply an answer that would be great. Thanks.