1

I have such a bash command ...

psql -c "SELECT datname FROM pg_database WHERE datname LIKE 'efa%' OR datname LIKE 'geocms%';"

and am wondering how to wrap this into watch -cd "<command>" properly. The excess of quotes is to be avoided.

tried those 2 without success

watch -cd `psql -c "SELECT datname FROM pg_database WHERE datname LIKE 'efa%';"`
watch -cd "psql -c \"SELECT datname FROM pg_database WHERE datname LIKE 'efa%';\""

EDIT:

escaping excess " with \"works actually:

watch -cd "psql -c \"SELECT datname FROM pg_database WHERE datname LIKE 'efa%';\""

3
  • 2
    I can see why your first attempt fails, but what happens when you try the last variation? Do you get any error messages at all? What does "without success" actually mean? Commented Feb 22, 2023 at 12:14
  • 1
    Your last suggestion (or a very close approximation to it) runs for me Commented Feb 22, 2023 at 12:23
  • 1
    sorry, you ar right the second version works. I just did not look at it correctly somehow. Sorry, for the false alarm Commented Feb 22, 2023 at 13:32

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.