Where have the spaces gone?

Where have the spaces gone?

Post by JGM_van_Ra » Wed, 24 Mar 1999 04:00:00




> Hi,

> 1. Here's a script.
> ========================================
> #!/bin/csh -f
> set aaa = "A       B                  C"
> echo aaa = "$aaa"

> set bbb = `echo "$aaa"`
> echo bbb = "$bbb"
> ========================================

> 2. And here are the running results.
> ========================================
> aaa = A       B                  C
> bbb = A B C             ### Where have the spaces gone? ###
> ========================================

Hi,

Why not like this

#!/bin/csh -f
set aaa = "A       B                  C"
echo aaa = "$aaa"

set bbb = "$aaa"
echo bbb = "$bbb"
          Jos van Ras

*** Philips Medical Systems Netherlands
*** System Dev. Cardio/Vascular
*** Hardware, Librarian & Support Unix
*** The Netherlands

*** Homepage:http://www.jgmvanras.demon.nl/

 
 
 

Where have the spaces gone?

Post by Ken Pizzi » Wed, 24 Mar 1999 04:00:00


On Tue, 23 Mar 1999 12:54:14 GMT,


>#!/bin/csh -f
>set aaa = "A       B                  C"
>echo aaa = "$aaa"

>set bbb = `echo "$aaa"`
>echo bbb = "$bbb"
>aaa = A       B                  C
>bbb = A B C             ### Where have the spaces gone? ###

They've gone on tokenization vacation.  Try altering your quoting:
  % set aaa = "A       B                  C"
  % set bbb = "`echo '$aaa'`"
  % echo bbb = "$bbb"
  bbb = A       B                  C

                --Ken Pizzini

 
 
 

Where have the spaces gone?

Post by Martin Rams » Thu, 25 Mar 1999 04:00:00


On Tue, 23 Mar 1999 20:14:30 GMT,


> > set bbb = `echo "$aaa"`
> > echo bbb = "$bbb"
[...]
> The short answer is that "echo" condensed them.

I don't think this is right.  IMHO the problem is that the command
substitution should be quoted!

Regards,
  Martin

 
 
 

Where have the spaces gone?

Post by bmar.. » Thu, 25 Mar 1999 04:00:00



   >Hi,
   >1. Here's a script.
   >========================================
   >#!/bin/csh -f
   >set aaa = "A       B                  C"
   >echo aaa = "$aaa"
   >set bbb = `echo "$aaa"`
   >echo bbb = "$bbb"
   >========================================
   >2. And here are the running results.
   >========================================
   >aaa = A       B                  C
   >bbb = A B C             ### Where have the spaces gone? ###
   >========================================

set bbb="`echo \"$aaa\"`"; # or simply  set bbb="$aaa"

Net-Tamer V 1.08X - Test Drive

 
 
 

Where have the spaces gone?

Post by Chris Costel » Tue, 27 Apr 1999 04:00:00



> Hi,

> 1. Here's a script.
> ========================================
> #!/bin/csh -f
> set aaa = "A       B                  C"
> echo aaa = "$aaa"

> set bbb = `echo "$aaa"`
> echo bbb = "$bbb"
> ========================================

> 2. And here are the running results.
> ========================================
> aaa = A       B                  C
> bbb = A B C             ### Where have the spaces gone? ###
> ========================================

>         Thanks in advance,
>         Alex

   Try this example:

/usr/home/chris/tmp$ cat foo.csh
echo `echo 'A     B     C     D     E    F    G  H IJKMNOPQRSTUVWXYZ'`
echo "`echo 'A     B     C     D     E    F    G  H IJKMNOPQRSTUVWXYZ'`"
/usr/home/chris/tmp$ csh foo.csh
A B C D E F G H IJKMNOPQRSTUVWXYZ
A     B     C     D     E    F    G  H IJKMNOPQRSTUVWXYZ

   Notice the quotes on the second one!

   Here's how it works:

echo A    B    C    D    E
echo "A    B    C    D    E"

echo `echo "A    B"`

   It takes some figuring...

--
Chris Costello
How do I set my laser printer on stun?