-1

I'm trying to replace below specific lines in a file

/ACCOUNT/passwd=
/BMC/CONFIRMATION/PASSWORD=

I need help in preparing the sed command

The required output would look something like this

/ACCOUNT/passwd=-2$-$A88CA7BD3DADDDFFC
/TMC/CONFIRMATION/PASSWORD=-2$-$A88CA7BD3DADDDFFC

Any help is appreciated.

Harshal
  • 1
  • 2
  • 1
    please add the code you've tried to solve this.. if you are new to sed, please go through https://stackoverflow.com/tags/sed/info and ask question when you've tried something.. – Sundeep May 30 '18 at 13:04
  • where is `backslash`? – Kent May 30 '18 at 13:13
  • Sorry I mean forward slash – Harshal May 30 '18 at 13:29
  • Are you sure `BMC` gets changed to `TMC`? – Bohemian May 30 '18 at 13:33
  • It may or may not... so there are different lines in the file, that I need to replace, in some lines i need to replace BMC to TMC and in some lines i need to just add the string at the end for eg : from : /TMC/CONFIRMATION/PASSWORD= TO : /TMC/CONFIRMATION/PASSWORD=-2$-$A88CA7BD3DADDDFFC – Harshal May 30 '18 at 13:35
  • 1
    Possible duplicate of [How to replace strings containing slashes with sed?](https://stackoverflow.com/questions/16790793/how-to-replace-strings-containing-slashes-with-sed) – Benjamin W. May 30 '18 at 15:32

1 Answers1

-1

There is nothing special about the forward slash, except if you choose to use it as the delimiter in your sed command, so don’t:

sed 's,ACCOUNT/passwd=,ACCOUNT/passwd=-2$-$A88CA7BD3DADDDFFC,g'

And similar for other target strings.

Here I’ve used a comma as the delimiter. You can choose another character as you prefer.

Sundeep
  • 23,246
  • 2
  • 28
  • 103
Bohemian
  • 412,405
  • 93
  • 575
  • 722