[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash scripting question (variables and spaces)



Karsten Heymann, Tue, Mar 19, 2002 at 08:35:53PM +0100: 
> Hi,
> 
> I have once again come upon bash problem I can't solve. I'm writing a
> little bash frontend and one of the programs expects a option that includes
> spaces and is composed from two other shell var's. Example:
> 
> #!/bin/bash
> A="Hello"
> B="Karsten"
> C=$A $B 
> someprog --greeting $C
> 
> Whatever I do now, --greeting receices only the "Hello" part. I've
> tried some other variants too:
> 
> C="$A $B"
> C=\"$A $a\B"
> C='$A $B'
> C=$A\ $B
> C=`echo $A $B`
> 
> What works is 
> someprog --greeting "Hello Karsten"
> but that's no solution.
> 

Try this:

#!/bin/bash
A="Hello"
B="World"
C="$A $B"

someprog --greeting "$C"


That should do it for you.

g



-- 
Brought to you by Debian 3.0
Linux took 2.4.16 #1 SMP Sat Jan 5 12:52:24 EST 2002 i686 unknown

Attachment: pgpvMtERSZiFt.pgp
Description: PGP signature


Reply to: