Results 1 to 3 of 3
I've been googling and fooling with this for quite some time, and although it seems simple enough, I haven't been able to figure it out.
I've got data that looks ...
- 12-03-2010 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 8
[SOLVED] Vim: Find line and insert line below it
I've been googling and fooling with this for quite some time, and although it seems simple enough, I haven't been able to figure it out.
I've got data that looks like:
dn: uid=bob$,ou=Computers,dc=null,dc=com
I need to find all lines that have "ou=Computers". and go to the end of the line, insert a new line, and put in "objectClass: account" , so the end result would be:
dn: uid=bob$,ou=Computers,dc=null,dc=com
objectClass: account
every time I try to do this I end up creating a new line at the end of "ou=Computers" and bringing the rest of the line down to the new line.
Could someone please guide me to the correct way of doing this?
Thanks!
- 12-03-2010 #2
I would do that with sed but if you need to accomplish it with vim run this command:
If needed, customize the regular expression.Code::%s/^\(dn: uid=\w\+\$,ou=\w\+,dc=\w\+,dc=\w\+\m\)$/\1\robjectClass: account/
Refining Linux Advent calendar: “24 Outstanding ZSH Gems”
- 12-03-2010 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 8
You are the man!
That worked perfectly, now my LDAP loads fine
My eyes went crossed reading it, but it worked great, thanks again!


