The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed behavior on hp-ux andy2000 Shell Programming and Scripting 8 05-04-2007 09:23 PM
msginfo_msgmnb & IO behavior Negm SUN Solaris 1 04-26-2006 11:40 AM
Behavior of pthreads nhrraj High Level Programming 4 04-21-2006 03:11 AM
ls behavior AtleRamsli High Level Programming 10 03-26-2002 07:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-10-2009
Saurabh78 Saurabh78 is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 40
Echo behavior

Echo is removing extra blank spaces. See the command.

export INSTALLDIR=”First Second /Two Space”
echo $INSTALLDIR
out put: First Second /Two Space
Here only on blnak space is present while with command

Echo “$INSTALLDIR”
Out put: ”First Second /Two Space”
It’s correct output with two blank spaces.
Any one can pls. explains why echo is behaving like this.
  #2 (permalink)  
Old 02-10-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,928
Quote:
Originally Posted by Saurabh78 View Post
Echo is removing extra blank spaces. See the command.

export INSTALLDIR=”First Second /Two Space”
First off, the two spaces aren't visible unless you put code in code tags. [ code ] stuff [ /code ] without the extra spaces in the tags.

And the reason that the extra space is lost is because the shell splits commands apart on spaces, even if they're a single variable, nothing to do with echo. Your command, without the quotes, amounts to:

Code:
echo "First" "Second "/Two" "space"
You use quotes to tell the shell not to split a string apart.
  #3 (permalink)  
Old 02-10-2009
Saurabh78 Saurabh78 is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 40
Thanks
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0