Solved

Remove newline character from var

Posted on 2004-08-12
4
946 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

830 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