I have a file that I need to add a new blank line before every line that starts with dn:
This is the perl one liner I'm using now which is working but giving me a extra blank line
I do not want.
perl -pe '$_ = /manager.*?$/?"$_\n":"$_"'
file1.txt
This gives me a blank line after each line that starts with manager which is what I really need
but the problem here is some of these have two lines that start with manager so I get a blank line
after each line that starts with manager.
What I need is a blank line after each line that starts with manager, IF the next line starts with
dn:....
Here is a sample of what is in the file
dn: cn=Pete William 425874,ou=employee,o=xyz,c
=ab
manager: cn=Ben Tale 254879,ou=employee,o=xyz,c
=ab
manager: cn=lloyd Jones 325478,ou=employee,o=xyz,c
=ab
dn: cn=Rene Doe 458741,ou=employee,o=xyz,c
=ab
manager: cn=Erik Johston 698752,ou=employee,o=xyz,c
=ab
dn: cn=Ass9999 685741,ou=site,o=xyz,c=ab
manager: cn=Parijat Jones 368752,ou=employee,o=xyz,c
=ab
dn: cn=ber112 685478,ou=site,o=xyz,c=ab
manager: cn=Trevor Toby 685745,ou=employee,o=xyz,c
=ab
manager: cn=Gerardo Jones 698745,ou=employee,o=xyz,c
=ab
What I need to do is add a blank line to make it look like
dn: cn=Pete William 425874,ou=employee,o=xyz,c
=ab
manager: cn=Ben Tale 254879,ou=employee,o=xyz,c
=ab
manager: cn=lloyd Jones 325478,ou=employee,o=xyz,c
=ab
dn: cn=Rene Doe 458741,ou=employee,o=xyz,c
=ab
manager: cn=Erik Johston 698752,ou=employee,o=xyz,c
=ab
dn: cn=Ass9999 685741,ou=site,o=xyz,c=ab
manager: cn=Parijat Jones 368752,ou=employee,o=xyz,c
=ab
dn: cn=ber112 685478,ou=site,o=xyz,c=ab
manager: cn=Trevor Toby 685745,ou=employee,o=xyz,c
=ab
manager: cn=Gerardo Jones 698745,ou=employee,o=xyz,c
=ab
Start Free Trial