Comando para encontrar uma string dentro de um padrão

0

O conteúdo do arquivo de log é

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)

Grepping Caused para obter a próxima linha

bash-4.1$ a=$(awk '/Caused/{getline; print}' testError.log )
bash-4.1$ echo $a

Saída:

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)

Requer uma lista de todo o nome dos arquivos dentro do ()

A saída da lista deve ser:

CommentService.java
TestService.java
    
por Rohan Gala 30.03.2016 / 14:07

3 respostas

3

com sed :

$ sed -n '/Caused/{
  N
  s/.*\n[^(]*(//
  s/:[^:]*$//
  p
}' <file
    
por 30.03.2016 / 14:20
3

Usando grep , supõe que o nome do arquivo java consiste em apenas alfabetos, números e _

awk '/Caused/{getline; print}' testError.log | grep -oE '\w+\.java'

Usando sed para o nome do arquivo geral

awk '/Caused/{getline; print}' testError.log | sed -r 's/.*\((.*):.*//'
    
por 30.03.2016 / 14:32
2

Permanecendo com awk

awk '/Caused/{getline; match($0, /[^(]*\.java/); 
     if (RSTART)print(substr($0, RSTART, RLENGTH))}' file
    
por 30.03.2016 / 14:48