how to grab a string
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
how to grab a string
hi all,
I just have an import (more than 50k lines) from ldap directory and I need to grab just usernames. The user name starts with "cn=". I just need this part.
I also need, once I get the CN=usernames from the file, I want to add some context like following....
cn=username, ou=some, o=company.
Can I do that using just textpad?
Thanks for help
I just have an import (more than 50k lines) from ldap directory and I need to grab just usernames. The user name starts with "cn=". I just need this part.
I also need, once I get the CN=usernames from the file, I want to add some context like following....
cn=username, ou=some, o=company.
Can I do that using just textpad?
Thanks for help
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Thanks for your reply. Here is the input i have...
and also some cases the input is something like this...
once I copy to other file, I must add some dn to user. we can hard code OU and O as that is just one value.
Final out put should be as follows...
from this I need only "cn=*" part.<modify cached-time="20100412173739.761Z" class-name="User" event-id="pwd-subscribe" qualified-src-dn="O=some\OU=company\CN=I266668" src-dn="\TREE\some\company\I266668" src-entry-id="50207" timestamp="0#0">
and also some cases the input is something like this...
I also need get the "cn=some user" (please keep in mind that I have more 50k users in the file and I need to copy all these users(cn=some user and/or cn=somenumber) probably to other file)cn=some user, ou=some, o=company
once I copy to other file, I must add some dn to user. we can hard code OU and O as that is just one value.
Final out put should be as follows...
if the cn=somenumber output should be as follows...dn: cn=some user, ou=some, o=company
I hope you understand.dn: cn=somenumber, ou=some, o=company
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
OK I just want to copy "CN=someuser" from the input I given in previous, to other file.
or instead of copying to other file, leave the CN=someuser and remove the rest of from input file.
The one which you give me, is just replacing with full DN. I dont need other stuff from input file as I just need CN=someuser.
or instead of copying to other file, leave the CN=someuser and remove the rest of from input file.
The one which you give me, is just replacing with full DN. I dont need other stuff from input file as I just need CN=someuser.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
I think the replacement will work but the problem is, in the input file there is big difference in the users like below...
Thanks.
in this case I'm not sure how the replace will work. With the solution you gave me, I can only able to find CN=* value. once I got all CN's in my output file, then I can run replace, i think. so first think I want to have only CN's in the output file.<modify cached-time="20100412171458.455Z" class-name="User" event-id="JMS iTIM Driver#8287298363575512505" qualified-src-dn="O=some\ou=company\CN=I269972" src-dn="\TREE\some\company\I269972" src-entry-id="53859" timestamp="0#0">
<modify cached-time="20100412171502.280Z" class-name="User" event-id="pwd-subscribe" qualified-src-dn="O=some\ou=companyCN=U260366" src-dn="\TREE\some\company\\U260366" src-entry-id="43309" timestamp="0#0">
<modify cached-time="20100412171511.079Z" class-name="User" event-id="pwd-subscribe" qualified-src-dn="O=some\ou=company\CN=M002152" src-dn="\TREE\some\company\\M002152" src-entry-id="109849" timestamp="0#0">
<modify cached-time="20100412171526.775Z" class-name="User" event-id="pwd-subscribe" qualified-src-dn="O=some\ou=company\CN=U265165" src-dn="\TREE\some\company\U265165" src-entry-id="47873" timestamp="0#0">
Thanks.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
OK here is the input....
Thanks.
This is sample input and I have like 50K lines in my input file. From this file, I need "CN=*" in output file. The output file should look like this...<modify cached-time="20100412171458.455Z" class- name="User" event-id="JMS iTIM Driver#8287298363575512505" qualified-src-dn="O=some\ou=company\CN=I269972" src-dn="\TREE\some\company\I269972" src-entry-id="53859" timestamp="0#0">
<modify cached-time="20100412171502.280Z" class-name="User" event-id="pwd-subscribe" qualified-src-dn="O=some\ou=companyCN=U260366" src-dn="\TREE\some\company\\U260366" src-entry-id="43309" timestamp="0#0">
<modify cached-time="20100412171511.079Z" class-name="User" event-id="pwd-subscribe" qualified-src-dn="O=some\ou=company\CN=M002152" src-dn="\TREE\some\company\CN=M002152" src-entry-id="109849" timestamp="0#0">
<modify cached-time="20100412171526.775Z" class-name="User" event-id="pwd-subscribe" qualified-src-dn="O=some\ou=company\CN=U265165" src-dn="\TREE\some\company\CN=U265165" src-entry-id="47873" timestamp="0#0">
Hope you got this time...CN=I269972
CN=U260366
CN=M002152
CN=U265165
Thanks.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
OK thanks that did it as I want.
Now, to this output I need to add full DN. The first output file is like this...
Now, to this output I need to add full DN. The first output file is like this...
from this I need followingCN=I269972
CN=U260366
CN=M002152
CN=U265165
Thanks again.dn: CN=I269972, ou=some, ou=some, o=company
changetype: modify
add: someattribute
someattribute: values
dn: CN=U260366, ou=some, ou=some, o=company
changetype: modify
add: someattribute
someattribute: values
dn: CN=M002152, ou=some, ou=some, o=company
changetype: modify
add: someattribute
someattribute: values
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm