Tal Levi
Tal Levi

Reputation: 825

How to disable bash info prints

Im running the next postgres query using the next bash command.

sudo -u postgres bash -c "psql -d db -c \"SELECT ip FROM db_accounts;\"" \>/dev/null 

The output is a table but before the table is printed, I get the following info prints

> psql: /usr/lib64/libssl.so.10: no version information available
> (required by psql) psql: /usr/lib64/libcrypto.so.10: no version
> information available (required by /usr/pgsql-9.4/lib/libpq.so.5)
> psql: /usr/lib64/libssl.so.10: no version information available
> (required by /usr/pgsql-9.4/lib/libpq.so.5)

I want to run my command without these prints appearing.

I tried to change the end of the command >/dev/null to 2>/dev/null and indeed the prints were disable but my table was not fully displayed (out of 800 rows only 40 were displayed), Can someone help me please?

Upvotes: 0

Views: 168

Answers (2)

Tal Levi
Tal Levi

Reputation: 825

To fix want I wanted I added --pset pager=off to the psql to get the whole table and the disable the prints I change the end of the command to 2>/dev/null

final command: sudo -u postgres bash -c "psql --pset pager=off --quiet -d db -c \"SELECT ip FROM db_accounts;\"" 2>/dev/null

Upvotes: 0

zealous
zealous

Reputation: 7503

Use --quiet when you start psql

OR

It can be set in your postgresql.conf file by adding this

client_min_messages = warning

This blog is really helpful.

Upvotes: 1

Related Questions