pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
psql -F <TAB>
6+ messages / 4 participants
[nested] [flat]

* psql -F <TAB>
@ 2006-11-16 11:18 T E Schmitz <mailreg@numerixtechnology.de>
  2006-11-16 11:58 ` Re: psql -F <TAB> Alvaro Herrera <alvherre@commandprompt.com>
  0 siblings, 1 reply; 6+ messages in thread

From: T E Schmitz @ 2006-11-16 11:18 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: psql -F <TAB>
  2006-11-16 11:18 psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
@ 2006-11-16 11:58 ` Alvaro Herrera <alvherre@commandprompt.com>
  2006-11-16 12:09   ` Re: psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
  0 siblings, 1 reply; 6+ messages in thread

From: Alvaro Herrera @ 2006-11-16 11:58 UTC (permalink / raw)
  To: T E Schmitz <mailreg@numerixtechnology.de>; +Cc: 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: psql -F <TAB>
  2006-11-16 11:18 psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
  2006-11-16 11:58 ` Re: psql -F <TAB> Alvaro Herrera <alvherre@commandprompt.com>
@ 2006-11-16 12:09   ` T E Schmitz <mailreg@numerixtechnology.de>
  2006-11-16 12:37     ` Re: psql -F <TAB> Joe Conway <mail@joeconway.com>
  0 siblings, 1 reply; 6+ messages in thread

From: T E Schmitz @ 2006-11-16 12:09 UTC (permalink / raw)
  To: ; +Cc: 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: psql -F <TAB>
  2006-11-16 11:18 psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
  2006-11-16 11:58 ` Re: psql -F <TAB> Alvaro Herrera <alvherre@commandprompt.com>
  2006-11-16 12:09   ` Re: psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
@ 2006-11-16 12:37     ` Joe Conway <mail@joeconway.com>
  2006-11-16 14:31       ` Re: psql -F <TAB> Kazuyuki Maejima <kmaejima@oak.ocn.ne.jp>
  2006-11-16 15:36       ` Re: psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
  0 siblings, 2 replies; 6+ messages in thread

From: Joe Conway @ 2006-11-16 12:37 UTC (permalink / raw)
  To: mailreg@numerixtechnology.de; +Cc: 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: psql -F <TAB>
  2006-11-16 11:18 psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
  2006-11-16 11:58 ` Re: psql -F <TAB> Alvaro Herrera <alvherre@commandprompt.com>
  2006-11-16 12:09   ` Re: psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
  2006-11-16 12:37     ` Re: psql -F <TAB> Joe Conway <mail@joeconway.com>
@ 2006-11-16 14:31       ` Kazuyuki Maejima <kmaejima@oak.ocn.ne.jp>
  1 sibling, 0 replies; 6+ messages in thread

From: Kazuyuki Maejima @ 2006-11-16 14:31 UTC (permalink / raw)
  To: T E Schmitz <mailreg@numerixtechnology.de>; +Cc: 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




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: psql -F <TAB>
  2006-11-16 11:18 psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
  2006-11-16 11:58 ` Re: psql -F <TAB> Alvaro Herrera <alvherre@commandprompt.com>
  2006-11-16 12:09   ` Re: psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
  2006-11-16 12:37     ` Re: psql -F <TAB> Joe Conway <mail@joeconway.com>
@ 2006-11-16 15:36       ` T E Schmitz <mailreg@numerixtechnology.de>
  1 sibling, 0 replies; 6+ messages in thread

From: T E Schmitz @ 2006-11-16 15:36 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2006-11-16 15:36 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-16 11:18 psql -F <TAB> T E Schmitz <mailreg@numerixtechnology.de>
2006-11-16 11:58 ` Alvaro Herrera <alvherre@commandprompt.com>
2006-11-16 12:09   ` T E Schmitz <mailreg@numerixtechnology.de>
2006-11-16 12:37     ` Joe Conway <mail@joeconway.com>
2006-11-16 14:31       ` Kazuyuki Maejima <kmaejima@oak.ocn.ne.jp>
2006-11-16 15:36       ` T E Schmitz <mailreg@numerixtechnology.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox