Solved

Remove newline character from var

Posted on 2004-08-12
4
944 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:mash79
  • 3
4 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 70 total points
ID: 11789960
use "tr"

eg:
echo "#$FILE_NAME#" | tr -d "\012"
0
 
LVL 38

Expert Comment

by:yuzh
ID: 11789965
or :

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


echo "#$FILE_NAME#"

0
 

Author Comment

by:mash79
ID: 11789984
Is this correct?
I am pretty sure it is working anyway:

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

Thanks for that!
0
 
LVL 38

Expert Comment

by:yuzh
ID: 11790007
Yes!

and you are welcome!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question