How to say this in Bash?

Matthew Seaman m.seaman at infracaninophile.co.uk
Mon May 25 17:21:05 UTC 2009


Unga wrote:
> --- On Mon, 5/25/09, Jerry <gesbbb at yahoo.com> wrote:
> 
>> From: Jerry <gesbbb at yahoo.com>
>> Subject: Re: How to say this in Bash?
>> To: freebsd-questions at freebsd.org
>> Date: Monday, May 25, 2009, 11:22 PM
>> On Mon, 25 May 2009 07:36:45 -0700
>> (PDT)
>> Unga <unga888 at yahoo.com>
>> wrote:
>>
>>> Here is what happens in bash shell:
>>> $ echo "${X}" > ${Z}
>>> bash: ${Z}: ambiguous redirect
>> Perhaps I am misinterpreting your question; however, if I
>> define both
>> ${X} and ${Z} in a script prior to running your snippet, I
>> do not
>> receive any error message. Could you show more info on how
>> you are
>> attempting to run this snippet?
>>
> 
> $ X='
>> XX1=YES
>> XX2=YES
>> '
> $ echo $X
> XX1=YES XX2=YES
> $
> $ Y='
>> YY1=YES
>> YY2=YES
>> '
> $ echo $Y
> YY1=YES YY2=YES
> $
> $ echo "${X}" > ${Z}
> bash: ${Z}: ambiguous redirect
> 
> I want to append all variables in X and Y into Z so that "echo $Z" should be:
> XX1=YES XX2=YES YY1=YES YY2=YES
> 
> I'm doing everything in command line not using any scripts.
> 

That's not how you set a variable.  Do it like this:

Z="${X} ${Y}"

You're mixing up variable initialisation with output to files.  

	Cheers,

	Matthew

-- 

Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                  Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090525/04c60bde/signature-0001.pgp


More information about the freebsd-questions mailing list