unexpected EOF while looking for matching `)'
6,724
Solution 1
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
)
Solution 2
Ikkachu is correct that the code, when not indented, should work fine on any reasonably modern version of Bash. However, I would add that you may find it easier to understand and debug if you use a "here string" instead of a "here doc":
var=$(sqlplus / as sysdba <<< 'select status from v$instance; exit;')
Or, use a standard pipeline:
var=$(echo 'select status from v$instance; exit;' | sqlplus / as sysdba)
Related videos on Youtube
Author by
Eternal Punishment
Updated on September 18, 2022Comments
-
Eternal Punishment over 1 year
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 )
-
Wildcard over 7 yearsGood catch. Note that if you use
<<-EOF
instead of<<EOF
, any leading tab characters (but not leading spaces!) will be ignored—for the whole "heredoc," not just the delimiter. -
Eternal Punishment over 7 yearsit is not indented. Sorry for the confusion.