I have a log file where data entries are as follows Each entry starts with time:
time: 20170509123420 dn: uid=abc,ou=People,dc=test,dc=example,dc=com changetype: modify replace: passwordAllowChangeTime replace: passwordExpirationTime replace: passwordRetryCount replace: pwdpolicysubentry replace: modifiersname modifiersname: uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot replace: modifytimestamp modifytimestamp: 20170509113420Z time: 20170509123621 dn: cn=nsPwPolicyContainer,dc=test,dc=example,dc=com changetype: add objectClass: nsContainer objectClass: top cn: nsPwPolicyContainer creatorsName: uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot modifiersName: uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoo Now I want to print as single line, only the entries between the time:. For eg, after time :, I want to print all records as single line, so in my case, it should print like
time: 20170509123420 dn: uid=abc,ou=People,dc=test,dc=example,dc=com changetype: modify replace: passwordAllowChangeTime - replace: passwordExpirationTime - replace: passwordRetryCount - replace: pwdpolicysubentry - replace: modifiersname modifiersname: uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoo t - replace: modifytimestamp modifytimestamp: 20170509113420Z I have tried with below commend, It's displaying on screen but when try to redirect/append it's not working.
tailf /var/log/dirsrv/slapd-ldap/audit | awk '/^time:/ {if (NR!=1)print"";printf $0}{printf $0}END{print"";}' | logger Is there any command for doing this?
>instead of|. because you want to put text into a file instead of passing it to a command. you should make clear what logger is.