Computing.Net > Forums > Unix > read id's from one text and put them in anoth

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

read id's from one text and put them in anoth

Reply to Message Icon

Name: erkutu
Date: June 2, 2009 at 04:21:05 Pacific
OS: unix
Subcategory: General
Comment:

Hello,

I've got a list of id's like 2300 entries..
my text of users, which is LIST.txt , is like this;
37565
24029
38421
35665

I want to pull every ID one by one and put them into a specific field in a text, LDIF.txt.. Here is my text,

dn: cn=eftmonitor,ou=eft,ou=roles,dc=isbank
changetype: modify
delete: nsroledn
nsroledn: cn=rl52882,ou=People,dc=isbank

I just want to replace the number after cn=rlXXXXX..
For example, If I modify regarding the list above;

dn: cn=eftmonitor,ou=eft,ou=roles,dc=isbank
changetype: modify
delete: nsroledn
nsroledn: cn=rl37565,ou=People,dc=isbank

dn: cn=eftmonitor,ou=eft,ou=roles,dc=isbank
changetype: modify
delete: nsroledn
nsroledn: cn=rl24029,ou=People,dc=isbank

dn: cn=eftmonitor,ou=eft,ou=roles,dc=isbank
changetype: modify
delete: nsroledn
nsroledn: cn=rl38421,ou=People,dc=isbank

dn: cn=eftmonitor,ou=eft,ou=roles,dc=isbank
changetype: modify
delete: nsroledn
nsroledn: cn=rl35665,ou=People,dc=isbank

There should be, one paragraph for one id, and also, there is an empty line after each paragraph. Can anyone help me? Thank you all in advance !

Cheers, Erkut



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: June 2, 2009 at 09:02:38 Pacific
Reply:

echo "" > LDIF.txt
for i in `cut -d: -f1 LIST.txt`; do
cat <<EOT >> LDIF.txt
dn: cn=eftmonitor,ou=eft,ou=roles,dc=isbank
changetype: modify
delete: nsroledn
nsroledn: cn=rl$i,ou=People,dc=isbank

EOT
done


0

Response Number 2
Name: erkutu
Date: June 2, 2009 at 13:45:43 Pacific
Reply:

Thank you David..
It works really fine.. You rock!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: read id's from one text and put them in anoth

find and replace stings www.computing.net/answers/unix/find-and-replace-stings/3865.html

wildcards searching loopq www.computing.net/answers/unix/wildcards-searching-loopq/6917.html

get data from file Linux www.computing.net/answers/unix/get-data-from-file-linux/4218.html