Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 32AA1632712 for ; Tue, 1 Jun 2010 02:30:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 75082-01 for ; Tue, 1 Jun 2010 05:30:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.egcrc.net (mail.egcrc.net [63.193.204.10]) by mail.postgresql.org (Postfix) with ESMTP id B052563221F for ; Tue, 1 Jun 2010 02:30:22 -0300 (ADT) Received: from EGCRC-EX04.egcrc.org ([::1]) by EGCRC-EX03.egcrc.org ([fe80::5c82:4343:5244:a0d5%11]) with mapi; Mon, 31 May 2010 22:30:20 -0700 From: Tena Sakai To: Greg Smith CC: Gabriele Bartolini , "pgsql-admin@postgresql.org" Date: Mon, 31 May 2010 22:27:59 -0700 Subject: Re: What is field separator? Thread-Topic: [ADMIN] What is field separator? Thread-Index: AcsBN6amu9oNvB56Q3SNnGDVuAc5HgAE4vB/ Message-ID: In-Reply-To: <4C04798D.70606@2ndquadrant.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-Entourage/13.4.0.100208 acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-10 required=5 tests=BAYES_20=-0.001 X-Spam-Level: X-Archive-Number: 201006/3 X-Sequence-Number: 34781 Many thanks, Greg! I got it to work by emulating what you wrote. But I think you meant -A, not -At below. >> psql -c "select name,setting from pg_settings limit 1" -d postgres -At >> -F $'\t' Regards, Tena Sakai tsakai@gallo.ucsf.edu On 5/31/10 8:07 PM, "Greg Smith" wrote: > Tena Sakai wrote: >> $ echo "select marker, p, afreq from gallo.fbat_sdsdecode limit 10" | = \ >>> psql -P 'format=3Dunaligned' -P 'fieldsep=3D\t' -t -f - musket >> What's denoted as \t is not a tab character. It is a two character >> sequence backslash followd by a t. I have tried all other possibilities >> such as \\t , "\t", etc that I can think of, but I cannot get an honest = to >> god tab character to appear as field separator. >=20 > Yeah, that's a tough one. In bash you can use ANSI C quoting to pull > this off: >=20 > psql -c "select name,setting from pg_settings limit 1" -d postgres -At > -F $'\t' >=20 > See http://wiki.bash-hackers.org/syntax/quoting for more information. > Portability to other shells I'm not sure about. >=20 > Note that I did two other things a little differently than your example, > as well as tightening up the abbreviations: >=20 > -Putting the command in -c " " is just better all around than piping > into psql using echo. It even works with multi-line input, i.e.: >=20 > psql -c " > select 1 > " >=20 > -Explicitly specifying the database manually using -d makes what's > happening easier to follow than expecting people to know the convention > that the first non-option passed to psql is a database name.