Lists: | pgsql-sql |
---|
From: | T E Schmitz <mailreg(at)numerixtechnology(dot)de> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | psql -F <TAB> |
Date: | 2006-11-16 11:18:48 |
Message-ID: | 455C4918.4020604@numerixtechnology.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
I have written a shell script to export data:
psql -A -t -U $DBUSER -d $DB -c "$QUERY" -F ' '
Currently, I am using spaces as field separator but what I really want
is tabs.
How can I specify a TAB character with the -F option?
--
Regards,
Tarlika Elisabeth Schmitz
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | T E Schmitz <mailreg(at)numerixtechnology(dot)de> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: psql -F <TAB> |
Date: | 2006-11-16 11:58:12 |
Message-ID: | 20061116115812.GB19298@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
T E Schmitz wrote:
> I have written a shell script to export data:
>
> psql -A -t -U $DBUSER -d $DB -c "$QUERY" -F ' '
>
> Currently, I am using spaces as field separator but what I really want
> is tabs.
>
> How can I specify a TAB character with the -F option?
This is really a shell question. On those I know, you'd type ^V <tab>.
(Maybe it would work to use '\t' as well, not sure if psql interprets
that.)
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
From: | T E Schmitz <mailreg(at)numerixtechnology(dot)de> |
---|---|
To: | |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: psql -F <TAB> |
Date: | 2006-11-16 12:09:34 |
Message-ID: | 455C54FE.5090902@numerixtechnology.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Alvaro Herrera wrote:
> T E Schmitz wrote:
>
>>I have written a shell script to export data:
>>
>>psql -A -t -U $DBUSER -d $DB -c "$QUERY" -F ' '
>>
>>Currently, I am using spaces as field separator but what I really want
>>is tabs.
>>
>>How can I specify a TAB character with the -F option?
>
>
> This is really a shell question. On those I know, you'd type ^V <tab>.
True.
Ctrl-V <tab> works fine on the command-line.
> (Maybe it would work to use '\t' as well, not sure if psql interprets
> that.)
Unfortunately, it doesn't. As far as I know -F literally wants a <tab.
character and how I get it in really is a shell question.
Sorry for having gone off-topic. I was just hoping something like \t
could be passed, too.
--
Regards,
Tarlika Elisabeth Schmitz
From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | mailreg(at)numerixtechnology(dot)de |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: psql -F <TAB> |
Date: | 2006-11-16 12:37:02 |
Message-ID: | 455C5B6E.1070403@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
T E Schmitz wrote:
> Alvaro Herrera wrote:
>
>> T E Schmitz wrote:
>>
>>> I have written a shell script to export data:
>>>
>>> psql -A -t -U $DBUSER -d $DB -c "$QUERY" -F ' '
>>>
>>> Currently, I am using spaces as field separator but what I really
>>> want is tabs.
>>>
>>> How can I specify a TAB character with the -F option?
> Sorry for having gone off-topic. I was just hoping something like \t
> could be passed, too.
>
Try:
psql -A -t -U $DBUSER -d $DB -c "$QUERY" -F $'\t'
see:
man bash
HTH,
Joe
From: | Kazuyuki Maejima <kmaejima(at)oak(dot)ocn(dot)ne(dot)jp> |
---|---|
To: | T E Schmitz <mailreg(at)numerixtechnology(dot)de> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: psql -F <TAB> |
Date: | 2006-11-16 14:31:57 |
Message-ID: | 455C765D.7030504@oak.ocn.ne.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Joe Conway wrote:
> Try:
> psql -A -t -U $DBUSER -d $DB -c "$QUERY" -F $'\t'
That's excellent, but please let me post a different way :)
by passing commands from stdin:
#!/bin/sh
cat <<EOT | psql -q -A -t -U $DBUSER -d $DB
\f '\t'
$QUERY
EOT
I think this will work even if your /bin/sh is not bash
(like FreeBSD and NetBSD).
Cheers,
Kazuyuki
From: | T E Schmitz <mailreg(at)numerixtechnology(dot)de> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: psql -F <TAB> |
Date: | 2006-11-16 15:36:03 |
Message-ID: | 455C8563.9030207@numerixtechnology.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Joe Conway wrote:
> T E Schmitz wrote:
>
>> Alvaro Herrera wrote:
>>
>>> T E Schmitz wrote:
>>>
>>>> I have written a shell script to export data:
>>>>
>>>> psql -A -t -U $DBUSER -d $DB -c "$QUERY" -F ' '
>>>>
>>>> How can I specify a TAB character with the -F option?
>
> Try:
> psql -A -t -U $DBUSER -d $DB -c "$QUERY" -F $'\t'
You're a star - that does the trick!
Regards,
Tarlika Elisabeth Schmitz