I am trying to generate some scripts to help manage an Oracle database. When I check the value returned from Oracle it has a leading carriage return in the variable. Is there a way to prevent this? Is there a way to easily strip out the carriage return. See code and output below.
LASTFILE=$(sqlplus -s "/ as sysdba" <<EOF
set head off
select file_name from dba_data_files
where tablespace_name = upper('$TABLESPACE') and
file_id in (select max(file_id) from dba_data_files
where tablespace_name = upper('$TABLESPACE'));
exit
EOF)
echo "Last data file = $LASTFILE"