How to replace all / by . only in the sentence after the = ?

For example, from this:

/buttress_unit/buttress_top/buttress_i_ps_but_cio_m1_i_but_m1_tx_wrapper_m1_pref_fifo_array_29__stream_id_3_0 = buttress_unit/buttress_top/buttress/i_ps_but_cio_m1/

I want to do this:

/buttress_unit/buttress_top/buttress_i_ps_but_cio_m1_i_but_m1_tx_wrapper_m1_pref_fifo_array_29__stream_id_3_0 = buttress_unit.buttress_top.buttress.i_ps_but_cio_m1.

you can try

sed ':label
  t label

The s substitute looks for = followed by anything ending with /. The capture with the parentheses excludes the final /. The replacement string copies the capture, and adds a dot. However, you cannot just add a g to do this globally, as sed wont look a 2nd time at the chars it has already matched. So you add a loop with a conditional goto (to avoid an infinite loop). t means goto the label label if the previous commands made a change to the line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.