用于解析破折号 (--) 之间的行的 Bash 脚本

用于解析破折号 (--) 之间的行的 Bash 脚本

我需要能够解析双破折号 (--) 之间的行并创建具有以下输出的 csv 文件。

所需的 CSV 输出:

<DATE>,<TIME>,<USER>,<STATUS>,<ERROR-TYPE>
05/29/18,15:21:00,testuser1,error,LDAP_INSUFFICIENT_RIGHTS
05/29/18,15:21:39,testuser2,success,NONE

示例日志文件:

--
[05/29/18 15:21:00.083]:AD-WIN-DEV ST:
<nds dtdversion="1.1" ndsversion="8.7">
<source>
<product asn1id="" build="20140409_120000" instance="\DEVIDMV\services\IDM\Driver Set\AD-WIN-DEV" version="4.0.0.4">AD</product>
<contact>NetIQ Corporation</contact>
</source>
<output>
<status event-id="pwd-subscribe" level="error" type="driver-general">
  <message>Password set failed.</message>
  <ldap-err ldap-rc="50" ldap-rc-name="LDAP_INSUFFICIENT_RIGHTS">
    <client-err ldap-rc="50" ldap-rc-name="LDAP_INSUFFICIENT_RIGHTS">Insufficient Rights</client-err>
    <server-err>00000005: SecErr: DSID-031A1256, problem 4003 (INSUFF_ACCESS_RIGHTS), data 0
</server-err>
    <server-err-ex win32-rc="5"/>
  </ldap-err>
  <operation-data DNForErrorReporting="\DEVIDMV\DEV\Vault\Active\testuser1" OpForErrorReporting="modify-password">
--
[05/29/18 15:21:39.031]:AD-WIN-DEV ST:
<nds dtdversion="1.1" ndsversion="8.7">
<source>
<product asn1id="" build="20140409_120000" instance="\DEVIDMV\services\IDM\Driver Set\AD-WIN-DEV" version="4.0.0.4">AD</product>
<contact>NetIQ Corporation</contact>
</source>
<output>
<status event-id="pwd-subscribe" level="success">
  <operation-data DNForErrorReporting="\DEVIDMV\DEV\Vault\Active\testuser2" OpForErrorReporting="modify-password">
    <password-subscribe-status>
      <association>a7de088a928d46479f86d9bc428b301b</association>
    </password-subscribe-status>
  </operation-data>
</status>
</output>
</nds>
--

相关内容