Re: [SQL] How would I get rid of trailing blank line?
Re: [SQL] How would I get rid of trailing blank line?
"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
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
Re: [SQL] How would I get rid of trailing blank line?
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
Re: [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