Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Remove newline character from var

Posted on 2004-08-12
4
Medium Priority
?
954 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 280 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

916 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