[Windows 10]Problem escaping dollar sign contained in tablename for /copy command in psql

In both POSIX-compatible shells such as bash and in PowerShell, $ is a metacharacter, which – in unquoted use or inside "..." – requires escaping in order to be interpreted verbatim (in order to be passed through to a command as-is).

However, the escape character differs between these two shells:

  • For POSIX-compatible shells it is \:
psql -d trm -h localhost -p 5432 -U postgres -c "\COPY ts_dev.tbl\$trm_secndry_readings from 'FILEPATH' with delimiter ',' ;"
psql -d trm -h localhost -p 5432 -U postgres -c "\COPY ts_dev.tbl`$trm_secndry_readings from 'FILEPATH' with delimiter ',' ;"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top