Thread: Do not output header line in psql

Do not output header line in psql

From
Hans Ginzel
Date:
Hello!

How can I please get rid of the header line "List of relations" in the example below, please?

echo '\dt' |psql -nqaA -Pfooter=off

I can use the -t option, but it also removes the column headers I want to keep.

Regards,
Hans


Re: Do not output header line in psql

From
Yaser Raja
Date:
You can use "grep -v" to exclude this line as follows:

echo '\dt' |psql -nqaA -Pfooter=off | grep -v 'List of relations'

Regards
Yaser


On Mon, Feb 2, 2015 at 4:00 AM, Hans Ginzel <hans@matfyz.cz> wrote:
Hello!

How can I please get rid of the header line "List of relations" in the example below, please?

echo '\dt' |psql -nqaA -Pfooter=off

I can use the -t option, but it also removes the column headers I want to keep.

Regards,
Hans


--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

Re: Do not output header line in psql

From
Hans Ginzel
Date:
On Mon, Feb 02, 2015 at 11:48:45AM -0500, Yaser Raja wrote:
>   You can use "grep -v" to exclude this line as follows:
>   echo '\dt' |psql -nqaA -Pfooter=off | grep -v 'List of relations'
>   Regards
>   Yaser

Thank you, but that is ugly. There must not be table/view named like this, etc.
Which all strings need to be filtered – relations, roles,…?
Is there a clean solution, please?

Regards,
H.

>
>   On Mon, Feb 2, 2015 at 4:00 AM, Hans Ginzel <[1]hans@matfyz.cz> wrote:
>
>     Hello!
>     How can I please get rid of the header line "List of relations" in
>     the example below, please?
>     echo '\dt' |psql -nqaA -Pfooter=off
>     I can use the -t option, but it also removes the column headers I
>     want to keep.


Re: Do not output header line in psql

From
Tom Lane
Date:
Hans Ginzel <hans@matfyz.cz> writes:
> On Mon, Feb 02, 2015 at 11:48:45AM -0500, Yaser Raja wrote:
>> You can use "grep -v" to exclude this line as follows:
>> echo '\dt' |psql -nqaA -Pfooter=off | grep -v 'List of relations'

> Thank you, but that is ugly. There must not be table/view named like this, etc.
> Which all strings need to be filtered – relations, roles,…?
> Is there a clean solution, please?

I agree that grep seems like a pretty dangerous solution, but
"tail -n +2" would work reliably.

Or, instead of relying on \dt, you could do your own select from
information_schema.tables, and then you'd have more control over
the formatting, column headers, etc.

            regards, tom lane