从log4j日志文件中提取唯一值

use*_*413 0 bash awk grep sed

我无法从log4j文件中仅提取匹配的字符串:OPER ^.我可以从日志文件中的两个不同来源获取此值:

2012-01-26 03:06:45,428 INFO  [NP_OSS] OSSBSSGWIMPL6000|**OPR20120126120537008893**|GenServiceDeactivationResponse :: processRequestGenServiceDeactivationResponse() ::
Run Code Online (Sandbox Code Playgroud)

要么:

2012-01-26 03:06:45,411 INFO  [NP_OSS] MESSAGE_DATA = <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:ServiceDeactivationResponse xmlns:ns2="urn:ngn:foo"><MessageHeader><MessageTimeStamp>20120126031123</MessageTimeStamp>**<OperatorTrxID>OPR20120126120537008893</OperatorTrxID>**</MessageHeader></ns2:ServiceDeactivationResponse>
Run Code Online (Sandbox Code Playgroud)

我只需要提取值OPR* 我猜它更容易从第一个中提取它,因为它不涉及解析xml.

非常感谢您的帮助!

Ken*_*ent 5

也许我不太了解OP的问题,为什么一个简单的grep命令无法完成这项工作?

喜欢

grep -Po 'OPR\d+'
Run Code Online (Sandbox Code Playgroud)

两行的输出相同:

OPR20120126120537008893
Run Code Online (Sandbox Code Playgroud)