Echo behavior


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Echo behavior
# 1  
Old 02-10-2009
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  
Old 02-10-2009
Quote:
Originally Posted by Saurabh78
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  
Old 02-10-2009
Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk Behavior

Linux Release Uname details Data file Ive been at the command line for some time. Back as far as SCO and Interactive Unix. I have always used this construct without issues. I want to isolate the ip / field 1. As you can see .. the first line is "skipped". This works as... (6 Replies)
Discussion started by: sumguy
6 Replies

2. Shell Programming and Scripting

Unexpected Echo Behavior

Hello all, I have a basic issue that I can't seem to search for since I'm not sure how to describe the behavior. Could anyone kindly assist the novice? (Sample) File Data: bundle-ppp-1/1.78 bundle-ppp-1/2.80 bundle-ppp-1/1.79 bundle-ppp-1/2.81 bundle-ppp-1/1.80 bundle-ppp-1/2.82... (6 Replies)
Discussion started by: sjrupp
6 Replies

3. Shell Programming and Scripting

With that logic this echoes "echo". Question about echo!

echo `echo ` doesn't echoes anything. And it's logic. But echo `echo `echo ` ` does echoes "echo". What's the logic of it? the `echo `echo ` inside of the whole (first) echo, echoes nothing, so the first echo have to echo nothing but echoes "echo" (too much echoing :P):o (2 Replies)
Discussion started by: hakermania
2 Replies

4. HP-UX

Unusual Behavior?

Our comp-operator has come across a peculiar ‘feature'. We have this directory where we save all the reports that were generated for a particular department for only one calendar year. Currently there are 45,869 files. When the operator tried to backup that drive it started to print a flie-listing... (3 Replies)
Discussion started by: vslewis
3 Replies

5. UNIX for Dummies Questions & Answers

How to correctly use an echo inside an echo?

Bit of a weird one i suppose, i want to use an echo inside an echo... For example... i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos... echo "echo "hello"" >$file echo "echo "goodbye"" >$file ... (3 Replies)
Discussion started by: mokachoka
3 Replies

6. Shell Programming and Scripting

Difference between using "echo" builtin and /bin/echo

So in my shell i execute: { while true; do echo string; sleep 1; done } | read line This waits one second and returns. But { while true; do /bin/echo string; sleep 1; done } | read line continues to run, and doesn't stop until i kill it explicitly. I have tried this in bash as well as zsh,... (2 Replies)
Discussion started by: ulidtko
2 Replies

7. Shell Programming and Scripting

sed behavior on hp-ux

the sed command: sed 's/^*//' file does not work on HP-UX :-( but it works fine on Linux, content of file: <tab><tab>hello output should be: hello Any ideas?? Thank you Andy (8 Replies)
Discussion started by: andy2000
8 Replies

8. Programming

Behavior of pthreads

Hi All, I ve written a small program to get started off with pthreads. I somehow feel the program doesnt meet the purpose. Please find the code and the output below. Please find my question at the bottom. #include <pthread.h> #include <stdio.h> #include <stdlib.h> void *PrintThread1(void... (4 Replies)
Discussion started by: nhrraj
4 Replies

9. Programming

ls behavior

I put this here because it is a 'behavior' type question.. I seem to remember doing ls .* and getting all the .-files, like .profile .login etc. But ls .* doesn't do that, it lsts the contents of every .*-type subdirectory. Is it supposed to? I should think that a -R should be given to... (10 Replies)
Discussion started by: AtleRamsli
10 Replies
Login or Register to Ask a Question