Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id B76D1633110 for ; Tue, 1 Jun 2010 00:08:09 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 26970-03 for ; Tue, 1 Jun 2010 03:08:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by mail.postgresql.org (Postfix) with ESMTP id E6043632EF4 for ; Tue, 1 Jun 2010 00:08:01 -0300 (ADT) Received: from [192.168.0.105] (pool-96-244-14-10.bltmmd.fios.verizon.net [96.244.14.10]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0LxLzO-1PQ2ia3yo6-016k5B; Tue, 01 Jun 2010 05:07:59 +0200 Message-ID: <4C04798D.70606@2ndquadrant.com> Date: Mon, 31 May 2010 23:07:57 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Tena Sakai CC: Gabriele Bartolini , "pgsql-admin@postgresql.org" Subject: Re: What is field separator? References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1/6BD1gKStvanlOUeMhJqvxePeeUHp8PgxKJoK Hr7szjhV2882nCMEUEW5dE+0yXpb0dzQZSw6sxRJrGre3JM94q oeXwnqjm3ivvN0W5CU3byV+Jl4wH/SL X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-10 required=5 tests=BAYES_40=-0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/1 X-Sequence-Number: 34779 Tena Sakai wrote: > $ echo "select marker, p, afreq from gallo.fbat_sdsdecode limit 10" | \ > > psql -P 'format=unaligned' -P 'fieldsep=\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. Yeah, that's a tough one. In bash you can use ANSI C quoting to pull this off: psql -c "select name,setting from pg_settings limit 1" -d postgres -At -F $'\t' See http://wiki.bash-hackers.org/syntax/quoting for more information. Portability to other shells I'm not sure about. Note that I did two other things a little differently than your example, as well as tightening up the abbreviations: -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.: psql -c " select 1 " -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. -- Greg Smith 2ndQuadrant US Baltimore, MD PostgreSQL Training, Services and Support greg@2ndQuadrant.com www.2ndQuadrant.us