Re: psql and regex not like
От | Ron Johnson |
---|---|
Тема | Re: psql and regex not like |
Дата | |
Msg-id | CANzqJaA9ecP_CWWnaLd5agfZEJZ-Tk1joxk3w4wJJXbzuPw1Ww@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: psql and regex not like (hubert depesz lubaczewski <depesz@depesz.com>) |
Список | pgsql-general |
On Thu, Mar 6, 2025 at 6:11 AM hubert depesz lubaczewski <depesz@depesz.com> wrote:
On Thu, Mar 06, 2025 at 04:37:56AM -0500, Ron Johnson wrote:
> This statement runs great from the psql prompt. Does exactly what I want.
> select datname from pg_database WHERE datname !~ 'template|postgres' ORDER
> BY datname;
> But it doesn't work so well from the bash prompt. Not escaping the "!"
> generates a bunch of garbage, while escaping throws an sql syntax error.
The problem is that ! is magical in bash.
The solution is to not use it. Instead you can easily do:
psql -Xc "select datname from pg_database WHERE not datname ~ 'template|postgres' ORDER BY datname;"
I've used WHERE NOT ()" before. Should have thought of it here.
Thanks.
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
В списке pgsql-general по дате отправления: