0

I am executing multiline query and want to store result of query in bash variable. Following is the query. If I run it without storing its result then it works fine. But if I want to store its result then it fails. Can someone tell what I need to correct here to see the execution result of query.

result=$(psql postgresql://$USERNAME:$PASSWORD@$HOST:$PORT -c << EOF
CREATE DATABASE $DB_NAME ;
create user $USER with encrypted password '$PASSWORD';
grant all privileges on database $DB_NAME to $USER;

EOF)

echo $result
keepmoving
  • 1,813
  • 8
  • 34
  • 74

0 Answers0