Bash – unexpected EOF while looking for matching `)’

bashhere-stringsql

I'm simply trying to get the output from a sql statement and store in bash variable. I am getting " unexpected EOF while looking for matching `)' " error.
I don't see what i'm doing wrong. Why am I getting this error?

var=$($ORACLE_HOME/bin/sqlplus / as sysdba <<EOF  
select status from v\$instance;
exit;
EOF
)

Best Answer

Is your script indented like that? the delimiter for the here-doc has to be at the beginning of the line. This works for me:

#!/bin/bash
echo $(cat <<EOF
blah
EOF
)
Related Question