日志文件的内容是
Caused by: com.ofss.fc.framework.exception.BusinessException: The memo start date cannot be earlier than the process date.
at com.ofss.fc.domain.party.service.core.CommentService.validateMemos(CommentService.java:474)
at com.ofss.fc.lz.us.appx.party.service.core.ext.RegionalPartyAddressApplicationServiceSpiExt.preUpdatePartyAddress(RegionalPartyAddressApplicationServiceSpiExt.java:43)
at com.ofss.fc.appx.party.service.core.ext.PartyAddressApplicationServiceSpiExtExecutor.preUpdatePartyAddress(PartyAddressApplicationServiceSpiExtExecutor.java:82)
at com.ofss.fc.appx.party.service.core.PartyAddressApplicationServiceSpi.updatePartyAddress(PartyAddressApplicationServiceSpi.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: com.ofss.fc.framework.exception.BusinessException: The memo start date cannot be earlier than the process date.
at com.ofss.fc.domain.party.service.core.CommentService.validateMemos(TestService.java:474)
at com.ofss.fc.lz.us.appx.party.service.core.ext.RegionalPartyAddressApplicationServiceSpiExt.preUpdatePartyAddress(RegionalPartyAddressApplicationServiceSpiExt.java:43)
at com.ofss.fc.appx.party.service.core.ext.PartyAddressApplicationServiceSpiExtExecutor.preUpdatePartyAddress(PartyAddressApplicationServiceSpiExtExecutor.java:82)
at com.ofss.fc.appx.party.service.core.PartyAddressApplicationServiceSpi.updatePartyAddress(PartyAddressApplicationServiceSpi.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
GreppingCaused
获取下一行
bash-4.1$ a=$(awk '/Caused/{getline; print}' testError.log )
bash-4.1$ echo $a
输出:
com.ofss.fc.domain.party.service.core.CommentService.validateMemos(CommentService.java:474) at com.ofss.fc.domain.party.service.core.CommentService.validateMemos(TestService.java:474)
需要列出 () 内的所有文件名
列表的输出应该是:
CommentService.java
TestService.java
答案1
和sed
:
$ sed -n '/Caused/{
N
s/.*\n[^(]*(//
s/:[^:]*$//
p
}' <file
答案2
使用grep
, 假定 java 文件名仅由字母、数字和 _ 组成
awk '/Caused/{getline; print}' testError.log | grep -oE '\w+\.java'
用于sed
一般文件名
awk '/Caused/{getline; print}' testError.log | sed -r 's/.*\((.*):.*/\1/'
答案3
住在一起awk
awk '/Caused/{getline; match($0, /[^(]*\.java/);
if (RSTART)print(substr($0, RSTART, RLENGTH))}' file