help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] add and expand


From: Peter West
Subject: Re: [Help-bash] add and expand
Date: Tue, 6 Jun 2017 11:06:57 +1000

> On 6 Jun 2017, at 9:52 am, Val Krem <address@hidden> wrote:
> 
> Thank you Peter,
> What I did not mention in my previous posting was after adding a prefix I 
> want export the expanded variables  as one variable.I amde a littel progress
> 
> 
> #! /bash/bin
> 
> set — one two three

Not using arrays now.

> test1="${@/#/Number}"
> echo $test1
> resulted
>    Numberone Numbertwo Numberthree

test1 is a single variable.  The echo shows the contents of the variable test1. 
You may have problems with the use of the variable because the shell is reading 
the contents of test1 as three separate words, thanks to IFS, which treats 
space, tab and newline as word separators.

As long as you use “$test1” rather than the unquoted $test1, the contents will 
be treated as a single variable. What specific problems are you having?

> How do I wrap this in quotation mark and treat it as one variable?
> 
> test2="Numberone Numbertwo Numberthree"; export test2
> 
> echo ${test2}
> I should get this:-
> 
>    Numberone Numbertwo Numberthree


--
Peter West
address@hidden
This is the disciple who is bearing witness to these things…

Attachment: signature.asc
Description: Message signed with OpenPGP


reply via email to

[Prev in Thread] Current Thread [Next in Thread]