Jump to content

Replacing a character in a script [solved]


Recommended Posts

I have a script that is extracting some data from an old LDAP server, and creating an ldif file. The problem I have is the parameters on the new ldap server use a different format.

 

What I'm wanting to do, is replace a character, with another character. For example, this line:

 

mailAlternateAddress=

 

I want to replace the "=" with a ":" instead. How could I do this?

 

Here is the line that gets the data:

 

user_mailaltaddr=`./lds uid=$UUID mailAlternateAddress | grep -v uid= | grep -v version`

 

so what I'm wanting to do is find "mailAlternateAddress=" and change this to "mailAlternateAddress:"

Link to comment
Share on other sites

I solved it.

 

I couldn't use it on the variable, so I got it to create the file normally, and then I just did:

 

sed 's/mailAlternateAddress=/mailAlternateAddress:/g' old.ldif > new.ldif

 

this then read the first file created, and created a new file with the amendments.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...