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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...