I want to set all this syntax in variable
su -l postgres -c "psql -c \"CREATE DATABASE graphite WITH OWNER graphite\""
CREATE DATABASE
so I wrote this
res=$( su -l postgres -c "psql -c \"CREATE DATABASE graphite WITH OWNER graphite\"" )
CREATE DATABASE
but $res is empty
echo $res
I also tried to add " " but without success.
How to insert the results of
su -l postgres -c "psql -c \"CREATE DATABASE graphite WITH OWNER graphite\""
to a shell variable?
x=$(su -l postgres -c "psql -c \"CREATE TABLE test (id integer)\"")