[clue] shell scripting Q

Dan Kulinski daniel at kulinski.net
Mon Feb 11 17:03:08 MST 2013


Marcus,

I rushed my explanation and missed something.  You are quite right you
can't force expansion in single quotes.  What you do is something like the
following:
var="'scale=2;${total}/60'"; echo $var | bc

Dan


On Mon, Feb 11, 2013 at 5:00 PM, marcus hall <marcus at tuells.org> wrote:

> On Mon, Feb 11, 2013 at 03:27:08PM -0700, Dan Kulinski wrote:
> > When you use single quotes you stop variable expansion.  Try double
> quotes
> > or forcing expansion with scale='2;${total}/60'
> >
> > Dan
>
> Double quotes is definately the answer..  But, I don't understand what
> you're trying to say about "forcing expansion".
>
> Try the following:
>
> xxx=test
>
> echo $xxx
> echo "$xxx"
> echo '$xxx'
> echo ${xxx}
> echo "${xxx}"
> echo '${xxx}'
>
> I think you will find that the single quotes never perform variable
> substitutuion.  Where the curly braces are useful are when the variable
> is immediately followed by a character that could be part of a variable
> name.  For example:
>
> echo $xxx_yyy
> echo ${xxx}_yyy
>
> The first case tries to expand the variable xxx_yyy, while the second case
> expands the variable xxx and follows that expansion with "_yyy".  Sometimes
> it is very important, but usually it is not needed.
>
> marcus hall
> marcus at tuells.org
> _______________________________________________
> clue mailing list: clue at cluedenver.org
> For information, account preferences, or to unsubscribe see:
> http://cluedenver.org/mailman/listinfo/clue
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue/attachments/20130211/695d359e/attachment.html 


More information about the clue mailing list