From tsakai@gallo.ucsf.edu Thu Apr 2 21:33:57 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D40A964038D for ; Thu, 2 Apr 2009 18:33:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 98286-09 for ; Thu, 2 Apr 2009 18:33:56 -0300 (ADT) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id A663B64038A for ; Thu, 2 Apr 2009 18:33:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail12.egcrc.net (mail12.egcrc.net [63.193.204.12]) by mx1.hub.org (Postfix) with ESMTP id 146E0125A729 for ; Thu, 2 Apr 2009 18:33:55 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C9B3DA.B7C74DD0" Subject: How would I get rid of trailing blank line? Date: Thu, 2 Apr 2009 14:33:52 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: How would I get rid of trailing blank line? Thread-Index: Acmz2rfErFkl+aBTSduiNmkcf/8FRQ== From: "Tena Sakai" To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200904/21 X-Sequence-Number: 32367 This is a multi-part message in MIME format. ------_=_NextPart_001_01C9B3DA.B7C74DD0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Everybody, I am using postgres 8.3.4 on linux. I often use a line like: psql -tf query.sql mydatabase > query.out -t option gets rid of the heading and count report at the bottom. There is a blank line at the bottom, however. Is there any way to have psql not give me that blank line? Thank you for your help. Regards, Tena Sakai tsakai@gallo.ucsf.edu ------_=_NextPart_001_01C9B3DA.B7C74DD0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How would I get rid of trailing blank line?

Hi Everybody,

I am using postgres 8.3.4 on linux.
I often use a line like:
  psql -tf query.sql mydatabase > query.out

-t option gets rid of the heading and count
report at the bottom.  There is a blank line
at the bottom, however.  Is there any way to
have psql not give me that blank line?

Thank you for your help.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu

------_=_NextPart_001_01C9B3DA.B7C74DD0-- From tgl@sss.pgh.pa.us Thu Apr 2 23:02:01 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 93EE5638153; Thu, 2 Apr 2009 20:02:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 96329-09; Thu, 2 Apr 2009 20:01:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 758BB637FF4; Thu, 2 Apr 2009 20:01:24 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n32N1LMC014639; Thu, 2 Apr 2009 19:01:21 -0400 (EDT) To: "Tena Sakai" cc: pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: How would I get rid of trailing blank line? In-reply-to: References: Comments: In-reply-to "Tena Sakai" message dated "Thu, 02 Apr 2009 14:33:52 -0700" Date: Thu, 02 Apr 2009 19:01:21 -0400 Message-ID: <14638.1238713281@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/23 X-Sequence-Number: 32369 "Tena Sakai" writes: > I often use a line like: > psql -tf query.sql mydatabase > query.out > -t option gets rid of the heading and count > report at the bottom. There is a blank line > at the bottom, however. Is there any way to > have psql not give me that blank line? Doesn't look like it --- the final fputc('\n', fout); seems to be done unconditionally in all the output formats. I wonder if we should change that? I'm afraid it might break programs that are used to it :-( regards, tom lane From tsakai@gallo.ucsf.edu Fri Apr 3 01:25:33 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1091F6363F4; Thu, 2 Apr 2009 22:25:33 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 74344-07; Thu, 2 Apr 2009 22:25:20 -0300 (ADT) X-Greylist: delayed 03:51:33.864724 by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail12.egcrc.net (mail12.egcrc.net [63.193.204.12]) by mail.postgresql.org (Postfix) with ESMTP id 11265633665; Thu, 2 Apr 2009 22:25:28 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C9B3FB.115D2CF8" Subject: Re: How would I get rid of trailing blank line? Date: Thu, 2 Apr 2009 18:20:44 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] How would I get rid of trailing blank line? Thread-Index: Acmz5vGRmwvOs4UkSR2d0f3ufGaUvQAE3ejK References: <14638.1238713281@sss.pgh.pa.us> From: "Tena Sakai" To: "Tom Lane" Cc: , X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.045 tagged_above=0 required=5 tests=AWL=0.044, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200904/26 X-Sequence-Number: 32372 This is a multi-part message in MIME format. ------_=_NextPart_001_01C9B3FB.115D2CF8 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Tom, I am a bit surprised to hear that that '\n' is there unconditionally. But I am sure there are more pressing things for you to work on. It's something I can live with. Regards, Tena Sakai tsakai@gallo.ucsf.edu -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Thu 4/2/2009 4:01 PM To: Tena Sakai Cc: pgsql-sql@postgresql.org; pgsql-hackers@postgresql.org Subject: Re: [SQL] How would I get rid of trailing blank line?=20 =20 "Tena Sakai" writes: > I often use a line like: > psql -tf query.sql mydatabase > query.out > -t option gets rid of the heading and count > report at the bottom. There is a blank line > at the bottom, however. Is there any way to > have psql not give me that blank line? Doesn't look like it --- the final fputc('\n', fout); seems to be done unconditionally in all the output formats. I wonder if we should change that? I'm afraid it might break programs that are used to it :-( regards, tom lane ------_=_NextPart_001_01C9B3FB.115D2CF8 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [SQL] How would I get rid of trailing blank line?

Hi Tom,

I am a bit surprised to hear that that '\n'
is there unconditionally.  But I am sure
there are more pressing things for you to
work on.  It's something I can live with.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thu 4/2/2009 4:01 PM
To: Tena Sakai
Cc: pgsql-sql@postgresql.org; pgsql-hackers@postgresql.org
Subject: Re: [SQL] How would I get rid of trailing blank line?

"Tena Sakai" <tsakai@gallo.ucsf.edu> writes:
> I often use a line like:
>   psql -tf query.sql mydatabase > query.out

> -t option gets rid of the heading and count
> report at the bottom.  There is a blank line
> at the bottom, however.  Is there any way to
> have psql not give me that blank line?

Doesn't look like it --- the final fputc('\n', fout); seems to be
done unconditionally in all the output formats.  I wonder if we = should
change that?  I'm afraid it might break programs that are used to = it :-(

        =         =         regards, tom lane

------_=_NextPart_001_01C9B3FB.115D2CF8-- From andrew@dunslane.net Fri Apr 3 01:34:24 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 382BA632D79; Thu, 2 Apr 2009 22:34:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 77014-02; Thu, 2 Apr 2009 22:34:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from alexis.jtlnet.com (alexis.jtlnet.com [69.36.9.81]) by mail.postgresql.org (Postfix) with ESMTP id 1A935632B26; Thu, 2 Apr 2009 22:34:22 -0300 (ADT) Received: from [192.168.10.103] (cpe-075-177-154-027.nc.res.rr.com [::ffff:75.177.154.27]) (TLS: TLSv1/SSLv3,256bits,AES256-SHA) by alexis.jtlnet.com with esmtp; Thu, 02 Apr 2009 21:29:36 -0400 id 000848F5.49D56681.00001819 Message-ID: <49D56798.3090402@dunslane.net> Date: Thu, 02 Apr 2009 21:34:16 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.12) Gecko/20071019 Fedora/1.0.9-3.fc6 pango-text SeaMonkey/1.0.9 MIME-Version: 1.0 To: Tom Lane CC: Tena Sakai , pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [SQL] How would I get rid of trailing blank line? References: <14638.1238713281@sss.pgh.pa.us> In-Reply-To: <14638.1238713281@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.034 tagged_above=0 required=5 tests=AWL=0.034 X-Spam-Level: X-Archive-Number: 200904/153 X-Sequence-Number: 136256 Tom Lane wrote: > "Tena Sakai" writes: > >> I often use a line like: >> psql -tf query.sql mydatabase > query.out >> > > >> -t option gets rid of the heading and count >> report at the bottom. There is a blank line >> at the bottom, however. Is there any way to >> have psql not give me that blank line? >> > > Doesn't look like it --- the final fputc('\n', fout); seems to be > done unconditionally in all the output formats. I wonder if we should > change that? I'm afraid it might break programs that are used to it :-( > > > Right. There's a simple pipeline way to get rid of it: psql -t -f query.sql | sed -e '$d' > query.out cheers andrew From scott.marlowe@gmail.com Fri Apr 3 02:53:41 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1D6FD6354DA for ; Thu, 2 Apr 2009 23:53:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 90212-04 for ; Thu, 2 Apr 2009 23:53:30 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f167.google.com (mail-ew0-f167.google.com [209.85.219.167]) by mail.postgresql.org (Postfix) with ESMTP id 72554634505 for ; Thu, 2 Apr 2009 23:53:39 -0300 (ADT) Received: by ewy11 with SMTP id 11so1195484ewy.19 for ; Thu, 02 Apr 2009 19:53:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=/wtrOqYfmTvEAX9d/1Cr895yctBqmTgQs2GNmpFxzoY=; b=hE32cfeIcH7s0TD1Dp8e9bsOPXArzbsD2K1PEQ3M+gW6hz4BDN1KHu/WqAncXdjlmP GJWMkuV5M8ETxwBEKFHFkFPY8Kl3BlZPpS2TTp9rk+zcG0sGMUDyWKLTC6BJWO+FdwXx XdfhUXLBjUMVARZUzlP5KkCHq9y4CgDtHgU+c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=w5OUdxAqCSCa9/RJtY7Q1iiHkD8e/C7k7JF6iM21+iXc0yyLfEHhV4QblWGZwg8H4p xhOq5nJaIHjqbz/LttzxZCkrEeqd5Q9Ef7EhrSUgv3h+nTqJ7XQj5W0iZ3tLt1YMxZNN +ngJ/4LnRBV6Lugzm1pBRBckCQlds00oLRuFY= MIME-Version: 1.0 Received: by 10.210.38.17 with SMTP id l17mr126783ebl.45.1238727217223; Thu, 02 Apr 2009 19:53:37 -0700 (PDT) In-Reply-To: References: Date: Thu, 2 Apr 2009 20:53:37 -0600 Message-ID: Subject: Re: How would I get rid of trailing blank line? From: Scott Marlowe To: Tena Sakai Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL=0.003 X-Spam-Level: X-Archive-Number: 200904/27 X-Sequence-Number: 32373 On Thu, Apr 2, 2009 at 3:33 PM, Tena Sakai wrote: > Hi Everybody, > > I am using postgres 8.3.4 on linux. > I often use a line like: > =A0 psql -tf query.sql mydatabase > query.out > > -t option gets rid of the heading and count > report at the bottom.=A0 There is a blank line > at the bottom, however.=A0 Is there any way to > have psql not give me that blank line? Tired of those blank lines in your text files? Grep them away: psql -tf query.sql mydatabase | grep -v "^$" > query.out > > Thank you for your help. > > Regards, > > Tena Sakai > tsakai@gallo.ucsf.edu > --=20 When fascism comes to America, it will be the intolerant selling it as diversity. From tsakai@gallo.ucsf.edu Fri Apr 3 05:56:26 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2543963821F; Fri, 3 Apr 2009 02:56:26 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 27197-02; Fri, 3 Apr 2009 02:56:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail12.egcrc.net (mail12.egcrc.net [63.193.204.12]) by mail.postgresql.org (Postfix) with ESMTP id B37CE638A1C; Fri, 3 Apr 2009 02:56:06 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C9B420.E0268738" Subject: Re: [HACKERS] How would I get rid of trailing blank line? Date: Thu, 2 Apr 2009 22:52:09 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [HACKERS] [SQL] How would I get rid of trailing blank line? Thread-Index: Acmz/FAd0tnP6y7OQd6fOeciq4N12AAJAPmY References: <14638.1238713281@sss.pgh.pa.us> <49D56798.3090402@dunslane.net> From: "Tena Sakai" To: "Andrew Dunstan" , "Tom Lane" , Cc: , X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200904/28 X-Sequence-Number: 32374 This is a multi-part message in MIME format. ------_=_NextPart_001_01C9B420.E0268738 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Andrew, > Right. There's a simple pipeline way to get rid of it: > psql -t -f query.sql | sed -e '$d' > query.out Hi Scott, > Tired of those blank lines in your text files? Grep them away: > psql -tf query.sql mydatabase | grep -v "^$" > query.out Thank you Both. Regards, Tena Sakai tsakai@gallo.ucsf.edu -----Original Message----- From: Andrew Dunstan [mailto:andrew@dunslane.net] Sent: Thu 4/2/2009 6:34 PM To: Tom Lane Cc: Tena Sakai; pgsql-sql@postgresql.org; pgsql-hackers@postgresql.org Subject: Re: [HACKERS] [SQL] How would I get rid of trailing blank line? =20 Tom Lane wrote: > "Tena Sakai" writes: > =20 >> I often use a line like: >> psql -tf query.sql mydatabase > query.out >> =20 > > =20 >> -t option gets rid of the heading and count >> report at the bottom. There is a blank line >> at the bottom, however. Is there any way to >> have psql not give me that blank line? >> =20 > > Doesn't look like it --- the final fputc('\n', fout); seems to be > done unconditionally in all the output formats. I wonder if we should > change that? I'm afraid it might break programs that are used to it = :-( > > > =20 Right. There's a simple pipeline way to get rid of it: psql -t -f query.sql | sed -e '$d' > query.out cheers andrew ------_=_NextPart_001_01C9B420.E0268738 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: [HACKERS] [SQL] How would I get rid of trailing blank = line?

Hi Andrew,

> Right. There's a simple pipeline way to get rid of it:
>   psql -t -f query.sql | sed -e '$d' > query.out

Hi Scott,

> Tired of those blank lines in your text files?  Grep them = away:
> psql -tf query.sql mydatabase | grep -v "^$" > = query.out

Thank you Both.

Regards,

Tena Sakai
tsakai@gallo.ucsf.edu


-----Original Message-----
From: Andrew Dunstan [mailto:andrew@dunslane.net]
Sent: Thu 4/2/2009 6:34 PM
To: Tom Lane
Cc: Tena Sakai; pgsql-sql@postgresql.org; = pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] [SQL] How would I get rid of trailing blank = line?



Tom Lane wrote:
> "Tena Sakai" <tsakai@gallo.ucsf.edu> writes:
>  
>> I often use a line like:
>>   psql -tf query.sql mydatabase > query.out
>>    
>
>  
>> -t option gets rid of the heading and count
>> report at the bottom.  There is a blank line
>> at the bottom, however.  Is there any way to
>> have psql not give me that blank line?
>>    
>
> Doesn't look like it --- the final fputc('\n', fout); seems to = be
> done unconditionally in all the output formats.  I wonder if = we should
> change that?  I'm afraid it might break programs that are used = to it :-(
>
>
>  

Right. There's a simple pipeline way to get rid of it:

    psql -t -f query.sql | sed -e '$d' > query.out


cheers

andrew

------_=_NextPart_001_01C9B420.E0268738-- From greg@turnstep.com Mon Apr 6 02:22:16 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C85D3632662 for ; Sun, 5 Apr 2009 23:22:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 75173-08 for ; Sun, 5 Apr 2009 23:22:15 -0300 (ADT) Received: from mx3.hub.org (mx3.hub.org [206.223.169.73]) by mail.postgresql.org (Postfix) with ESMTP id 8F26F6324C2 for ; Sun, 5 Apr 2009 23:22:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tinlc.com (unknown [72.18.206.65]) by mx3.hub.org (Postfix) with ESMTP id 1FCDA37B50B for ; Sun, 5 Apr 2009 23:22:14 -0300 (ADT) Received: from biglumber.com ([72.18.206.64] helo=localhost) by tinlc.com with smtp (Exim 4.60) (envelope-from ) id 1LqeTH-00044m-LW; Sun, 05 Apr 2009 21:21:59 -0500 From: "Greg Sabino Mullane" To: pgsql-sql@postgresql.org Subject: Re: How would I get rid of trailing blank line? X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: Date: Mon, 6 Apr 2009 02:21:59 -0000 X-Mailer: JoyMail 2.01 Message-ID: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/39 X-Sequence-Number: 32385 -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 > report at the bottom. There is a blank line > at the bottom, however. Is there any way to > have psql not give me that blank line? Now that my presenation on psql is over :), I'll share my solution: psql -AX -qt -c "SELECT ..." | perl -pe 's/^\n// if $.<2' This strips a newline from the first line only of the output, and only if the line consists of nothing else. Highly recommended for cron. - -- Greg Sabino Mullane greg@turnstep.com End Point Corporation PGP Key: 0x14964AC8 200904052221 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iEYEAREDAAYFAknZZ0YACgkQvJuQZxSWSsiDAwCglJS9/juQLe8asY3sG9fagbeo 2V4An0p5U6UHGI1KXoe2qQvURX5E5BZo =Yy0J -----END PGP SIGNATURE----- From jasen@xnet.co.nz Fri Apr 10 15:09:49 2009 Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 22DF06338B3 for ; Fri, 10 Apr 2009 12:09:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 55590-07 for ; Fri, 10 Apr 2009 12:09:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from oberon.wxnz.net (oberon.wxnz.net [58.28.6.13]) by mail.postgresql.org (Postfix) with ESMTP id 4DA27633314 for ; Fri, 10 Apr 2009 12:09:46 -0300 (ADT) Received: from gonzo (ip-118-90-138-193.xdsl.xnet.co.nz [118.90.138.193]) by oberon.wxnz.net (Postfix) with ESMTP id E798C46C003 for ; Sat, 11 Apr 2009 03:09:43 +1200 (NZST) Received: from news by gonzo with local (Exim 4.69) (envelope-from ) id 1LsIMQ-0001LQ-Lp for pgsql-sql@postgresql.org; Sat, 11 Apr 2009 03:09:42 +1200 To: pgsql-sql@postgresql.org Path: not-for-mail From: Jasen Betts Newsgroups: gmane.comp.db.postgresql.sql Subject: Re: How would I get rid of trailing blank line? Date: 10 Apr 2009 15:09:42 GMT Organization: Dis (not Dat) Organisation Lines: 26 Message-ID: References: NNTP-Posting-Host: localhost Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reversiblemaps.ath.cx 1239376182 5170 127.0.0.1 (10 Apr 2009 15:09:42 GMT) X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-2 (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200904/51 X-Sequence-Number: 32397 On 2009-04-02, Tena Sakai wrote: > I am using postgres 8.3.4 on linux. > I often use a line like: > psql -tf query.sql mydatabase > query.out > > -t option gets rid of the heading and count > report at the bottom. There is a blank line > at the bottom, however. Is there any way to > have psql not give me that blank line? I ask postgres to format it for me instead of relying on psql psql db_name -c "copy (select * from foo ) to stdout;" this gives me postgres style tab separated values, but I can have CSV (or any otther format COPY can do) if I want. I usually use a more complex subquery with a list of columns and expressions, where, order by clauses, etc... ) I use this in a script that pulls data from one database and inserts in into another. Requires postgres 8.2 or later From david.paulo@legalfirst.com.au Sun Nov 15 02:17:32 2015 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zxmsm-0005mm-BD for pgsql-sql@arkaria.postgresql.org; Sun, 15 Nov 2015 02:17:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zxmsk-0004Mf-Nh for pgsql-sql@arkaria.postgresql.org; Sun, 15 Nov 2015 02:17:30 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zxmsj-0004Lp-55 for pgsql-sql@postgresql.org; Sun, 15 Nov 2015 02:17:29 +0000 Received: from mbob.nabble.com ([162.253.133.15]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Zxmsb-0000Sq-9Y for pgsql-sql@postgresql.org; Sun, 15 Nov 2015 02:17:26 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mbob.nabble.com (Postfix) with ESMTP id 341FA1A12BB6 for ; Sat, 14 Nov 2015 18:05:23 -0800 (PST) Date: Sat, 14 Nov 2015 19:17:19 -0700 (MST) From: "david.paulo" To: pgsql-sql@postgresql.org Message-ID: <1447553839377-5873931.post@n5.nabble.com> In-Reply-To: References: Subject: Re: How would I get rid of trailing blank line? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org The sed -e '$d' is nice but it has a downside - it will mask the return code from psql in the case when there is an error -- View this message in context: http://postgresql.nabble.com/How-would-I-get-rid-of-trailing-blank-line-tp2153908p5873931.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql