@Ignacio, I beg to differ. Certainly this is not something which can be done in one statement with plain regular expressions. But the sed command:
sed -e 's/([a-zA-Z])C/1 c/g' infile.txt
will replace all occurrences of ‘C’ with ‘ c’ when the ‘C’ is immediately preceded by a letter. All OP has to do is make 26 variants of this, which might be tedious. And getting the condition under which the case is altered might be difficult too but that’s always the case with using regular expressions for global search-and-replace.
Read more here: Source link