我有一个命令,可以提供大量输出,其中包含一些文件和其他详细信息的列表。该命令或脚本的示例输出如下所示。
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
================================================================================
我需要一个类似于下图所示的输出。如果可能的话,将其写入文件或删除编号会更有帮助。
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
答案1
如果您只想要带有 的行abc/xyz/
,您可以将命令通过管道传输到
| grep -o 'abc/xyz/.*' > output
-o
只需打印匹配的部分.*
该行上的任何字符>
将输出发送到文件output
答案2
如果您事先不知道文件将位于哪个目录中,则可以使用另一种方法,即丢弃明显不是文件名的所有内容:
sed '1,/FILES:$/d
/^$/d
/^===/d
/RESERVED:$/d
/ELEMENTS:/d
s/^ *[0-9]\+\. *//
s/ *\[.*//'