Obtém uma parte específica do texto da saída de um comando

0

Eu tenho um comando que dá saída uma saída grande com lista de alguns arquivos e outros detalhes. A saída de amostra desse comando ou script é mostrada abaixo.

HOST NAME: ABC.us.XYZ.com
DESCRIBING VIEW: ...
TRANS_STATE: OPEN

ALL AFFECTED FILES:
  1.    abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/EmailAddressEOImpl.java  [MERGE TO BRANCH -> st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown ]
  2.    abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/NationalIdentifierEOImpl.java  [MERGE TO BRANCH -> st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown ]
  3.    abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/PhoneEOImpl.java  [MERGE TO BRANCH -> st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown ]
  4.    abc/xyz/components/xyzCoreSetup/.adf/META-INF/connections.xml 
  5.    abc/xyz/components/xyzCoreSetup/absenceManagement/absences/ui/xyzAbsMgmtAbsencesUi.jpr 


CHECKEDOUT RESERVED:
  1.    abc/xyz/components/xyzCoreSetup/.adf/META-INF/connections.xml [edward_view2_brown]
  2.    abc/xyz/components/xyzCoreSetup/absenceManagement/absences/ui/xyzAbsMgmtAbsencesUi.jpr [edward_view2_brown]
  3.    abc/xyz/components/xyzCoreSetup/absenceManagement/accruals/ui/xyzAbsMgmtAccrualsUi.jpr [edward_view2_brown]
  4.    abc/xyz/components/xyzCoreSetup/absenceManagement/calendarEvents/ui/xyzAbsMgmtCalendarEventsUi.jpr [edward_view2_brown]
  5.    abc/xyz/components/xyzCoreSetup/absenceManagement/workSchedules/ui/xyzAbsMgmtWorkSchedsUi.jpr [edward_view2_brown]


BACKEND BRANCHED ELEMENTS:
================================================================================
abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/EmailAddressEOImpl.java@@/main/st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown/edward_tras1/1
abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/NationalIdentifierEOImpl.java@@/main/st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown/edward_tras1/1
================================================================================

Eu preciso de uma saída que será semelhante à mostrada abaixo. Escrevê-lo no arquivo ou remover a numeração será ainda mais útil, se possível.

  1.    abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/EmailAddressEOImpl.java  [MERGE TO BRANCH -> st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown ]
  2.    abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/NationalIdentifierEOImpl.java  [MERGE TO BRANCH -> st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown ]
  3.    abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/PhoneEOImpl.java  [MERGE TO BRANCH -> st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown ]
  4.    abc/xyz/components/xyzCoreSetup/.adf/META-INF/connections.xml 
  5.    abc/xyz/components/xyzCoreSetup/absenceManagement/absences/ui/xyzAbsMgmtAbsencesUi.jpr 
  1.    abc/xyz/components/xyzCoreSetup/.adf/META-INF/connections.xml [edward_view2_brown]
  2.    abc/xyz/components/xyzCoreSetup/absenceManagement/absences/ui/xyzAbsMgmtAbsencesUi.jpr [edward_view2_brown]
  3.    abc/xyz/components/xyzCoreSetup/absenceManagement/accruals/ui/xyzAbsMgmtAccrualsUi.jpr [edward_view2_brown]
  4.    abc/xyz/components/xyzCoreSetup/absenceManagement/calendarEvents/ui/xyzAbsMgmtCalendarEventsUi.jpr [edward_view2_brown]
  5.    abc/xyz/components/xyzCoreSetup/absenceManagement/workSchedules/ui/xyzAbsMgmtWorkSchedsUi.jpr [edward_view2_brown]
abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/EmailAddressEOImpl.java@@/main/st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown/edward_tras1/1
abc/xyz/components/xyzCore/people/core/protectedModel/src/oracle/apps/xyz/people/core/protectedModel/entity/NationalIdentifierEOImpl.java@@/main/st_abc_pt-v2mib/st_abc_pt-v2mibxyzgold/st_abc_pt-v2mibxyzgray/st_abc_pt-v2mibxyzbrown/edward_tras1/1
    
por Abhishek Kothari 30.01.2017 / 12:56

2 respostas

4

Se você quer apenas as linhas com abc/xyz/ , você pode canalizar a partir do seu comando para

| grep -o 'abc/xyz/.*' > output
  • -o apenas imprime a parte correspondente
  • .* quaisquer caracteres na linha
  • > envia a saída para o arquivo output
por 30.01.2017 / 13:02
0

Se você não sabe em qual diretório os arquivos estarão antes, você pode usar a abordagem alternativa de descartar tudo o que claramente não é um nome de arquivo:

sed '1,/FILES:$/d
     /^$/d
     /^===/d
     /RESERVED:$/d
     /ELEMENTS:/d
     s/^ *[0-9]\+\. *//
     s/ *\[.*//'
    
por 01.02.2017 / 08:42