sed: -e expression #1, char NN: invalid reference \1 on `s' command's RHS
This is a wiki page. Be bold and improve it!
If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.
For example, if want to change 'lNDISTINCT CHATTERING' to 'INDISTINCT CHATTERING', we may try this:
sed "s/l([A-Z])/I\1/" file.txt
which will produce the error:
"sed: -e expression #1, char 15: invalid reference \1 on `s' command's RHS"
This is because the parenthesis must be escaped thus:
sed "s/l\([A-Z]\)/I\1/" file.txt