Unfortunatly psql -l uses linewraps
example see output and regard the "access" column
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------------------+------------+----------+-------------+-------------+-----------------------
firstdb | postgres | UTF8 | de_DE.UTF-8 | de_DE.UTF-8 |
secnddb | scnduser | UTF8 | de_DE.UTF-8 | de_DE.UTF-8 |
thrddb | scnduser | UTF8 | de_DE.UTF-8 | de_DE.UTF-8 |
postgres | postgres | UTF8 | de_DE.UTF-8 | de_DE.UTF-8 |
template0 | postgres | UTF8 | de_DE.UTF-8 | de_DE.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | de_DE.UTF-8 | de_DE.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(6 rows)
hint even with some option, I can't get that gone:
$ psql -Atlqn firstdb|postgres|UTF8|de_DE.UTF-8|de_DE.UTF-8| secnddb|scnduser|UTF8|de_DE.UTF-8|de_DE.UTF-8| thrddb|scnduser|UTF8|de_DE.UTF-8|de_DE.UTF-8| postgres|postgres|UTF8|de_DE.UTF-8|de_DE.UTF-8| template0|postgres|UTF8|de_DE.UTF-8|de_DE.UTF-8|=c/postgres postgres=CTc/postgres template1|postgres|UTF8|de_DE.UTF-8|de_DE.UTF-8|=c/postgres postgres=CTc/postgres
Question Is there another way to get the list of databases in the same way \list prints it so I can use it in scripts for parsing with e.g. awk?