I am trying to add missing quotes at the ends of some lines in a text file.
I find that the regex [^\"]$ suffices to find lines with missing terminal doublequotes and so tried the following replacement using a backreference (which tbh I've never used before). Using parens around the 'capture group' I hoped that sed would allow backreference to that group, but
sed 's|([^\"]$)|\1\"|g' bigfile.tsv
sed: -e expression #1, char 17: invalid reference \1 on `s' command's RHS
and same if I don't escape the replacement quotes
sed 's|([^\"]$)|\1"|g' bigfile.tsv
(tho now its char 16 that's offensive) . How does the backreference go? https://xkcd.com/1171/