Remove newline character from var

Hi,
  I have a the following variable, which contains a newline character at the beginning.

  FILE_NAME=`${ORACLE_HOME}/bin/sqlplus -s   <<-EOF
                ${ORA_USER}/${ORA_PASSWORD}
                @${SQL_SCRIPT}
        EOF`


echo "#$FILE_NAME#"

returns:
#
testing.txt#

how can i get rid of it? I tried using sed and such, but i dont want echo to a file.

Thanks
mash79Asked:
Who is Participating?
 
yuzhConnect With a Mentor Commented:
use "tr"

eg:
echo "#$FILE_NAME#" | tr -d "\012"
0
 
yuzhCommented:
or :

FILE_NAME=`${ORACLE_HOME}/bin/sqlplus -s   <<-EOF
                ${ORA_USER}/${ORA_PASSWORD}
                @${SQL_SCRIPT}
        EOF | tr -d "\012" `


echo "#$FILE_NAME#"

0
 
mash79Author Commented:
Is this correct?
I am pretty sure it is working anyway:

FILE_NAME=`echo $FILE_NAME | tr -d "\012"`

Thanks for that!
0
 
yuzhCommented:
Yes!

and you are welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.