1

How can I adjust sed -e 's/(match other stuff too)[aA]/\1b/g' to have the replacing b match the case of the a being replaced? In this case only the single character is being replaced but the entire search can/should be case insensitive (I can address that separately with s///I I believe).

altendky
  • 4,176
  • 4
  • 29
  • 39

1 Answers1

1

This might work for you (GNU sed):

sed -rn 's/$/\nabAB/;:a;s/(match other stuff too)([aA])(.*\n.*\2(.).*)/\1\4\3/;ta;P' file

Append a lookup table to the end of the line and loop until all lookups have been substituted.

potong
  • 55,640
  • 6
  • 51
  • 83