All, I'm trying to use a variable for the filename portion of \copy. I'm calling psql on some SQL commands in a file from a shell script: FILETOLOAD="/var/tmp/filetoload.${$}" OPTIONS="--variable=outfile='${FILETOLOAD}'" psql ${OPTIONS} -f /some/file.sql In /some/file.sql: \copy table(f1, f2, f3) from :outfile with delimiter '|'; Which yields: psql:/some/file.sql:4: :outfile: No such file or directory An \echo :outfile command confirms that the single-quoted filename is making it to the SQL script, but it's not being used in the substitution by the \copy command. The only thing applicable to variable substitution with \copy I could find was a somewhat contradictory paragraph in the psql man page: The syntax of the command is similar to that of the SQL COPY(7) command. Note that, because of this, special parsing rules apply to the \copy command. In particular, the variable substitution rules and backslash escapes do not apply. Thanks for any suggestions. -- Gary Chambers -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general