Re: escape character for 'psql -c ' command

From: Derrick Rice <derrick(dot)rice(at)gmail(dot)com>
To: Gary Fu <gfu(at)sigmaspace(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: escape character for 'psql -c ' command
Date: 2010-11-16 19:15:00
Message-ID: AANLkTim-59e3JMyeL3nXOZF7YcTRU_3R-nfrf+n13uVD@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Please include the list when replying.

On Tue, Nov 16, 2010 at 11:45 AM, Gary Fu <gfu(at)sigmaspace(dot)com> wrote:

> Short answer: for simple commands, you can use shell-escaping of a
>> double-quoted string.
>>
>> psql -c "\\copy \"Table\" from 'text file'"
>>
>>
> This works on sh, but I tried this syntax on tcsh, it fails:
>
> 11:38am 72 gfu(at)modular:~/sybase2postgres> psql -c "\\copy \"Table\" from
> 'text file'"
> Unmatched ".
>
> How to make it work on tcsh ?
>

Consult your shell's documentation.

http://www.tcsh.org/tcsh.html/Lexical_structure.html

http://www.tcsh.org/tcsh.html/Special_shell_variables.html#backslash_quote

Apparently you can use "set backslash_quote=1" and then the original will
work. Read the warning above about backslash_quote:

Or use the long-version, which is pretty reliable.

Derrick

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Cook 2010-11-16 19:22:58 Re: Postgres forums ... take 2
Previous Message Chris Barnes 2010-11-16 19:11:32 Re: I want to create a read only database for a specified user.