public inbox for [email protected]
help / color / mirror / Atom feedRe: psql and regex not like
2+ messages / 2 participants
[nested] [flat]
* Re: psql and regex not like
@ 2025-03-06 11:11 hubert depesz lubaczewski <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: hubert depesz lubaczewski @ 2025-03-06 11:11 UTC (permalink / raw)
To: Ron Johnson <[email protected]>; +Cc: pgsql-general
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;"
Best regards,
depesz
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: psql and regex not like
@ 2025-03-06 11:34 Ron Johnson <[email protected]>
parent: hubert depesz lubaczewski <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Ron Johnson @ 2025-03-06 11:34 UTC (permalink / raw)
To: pgsql-general
On Thu, Mar 6, 2025 at 6:11 AM hubert depesz lubaczewski <[email protected]>
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!
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-03-06 11:34 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-06 11:11 Re: psql and regex not like hubert depesz lubaczewski <[email protected]>
2025-03-06 11:34 ` Ron Johnson <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox