I have something like this:
UPDATE table SET column=REGEXP_REPLACE(column, E'\[(.*)\]$', '');
Everything is ok with this query, but the problem exists when I want to do this from console, like here:
psql -U postgres db -c "UPDATE table SET column=REGEXP_REPLACE(column, E'\\[(.*)\\]$', '');"
I think there is a problem with escaping some characters, but I cannot handle it.
Assuming a Unix-like shell, as an alternative to passing the query with
-cand complicated multi-level quoting, it could be passed in its original form in the standard input using heredoc syntax: