I'm very new to scripting. I would like to add the output of the sql function given below to another variable for example:
month_end ()
{
mdate=$($SQLPLUS_HOME/sqlplus.exe -S $DBC << END
set pagesize 0 feedback off verify off heading off echo off;
select to_char(last_day(add_months(sysdate,-1)),'yyyymmdd') from dual;
exit;
END
)
}
when I echo the output from $mdate is perfect. (20160531)
But when I append to another varable, the whole value is broken ( _WORLD.txt instead of Hello_20160531_WORLD.txt).
FILENAME=Hello
EXTENSION=WORLD.txt
NAME=$FILENAME_${mdate}_${EXTENSION}
echo ${NAME}
NAME="$FILENAME_${mdate}_${EXTENSION}"andecho "$NAME"