[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] something about variable.
From: |
Bob Proulx |
Subject: |
Re: [Help-bash] something about variable. |
Date: |
Sun, 8 Jul 2012 22:45:31 -0600 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
lina wrote:
> echo -n "=PEARSON(B2:B43,$i 2:$i 43) "
Using 'echo' with -n isn't portable. Please consider using 'printf'
for that task instead. It will do what you want everywhere that you
care about.
> $i2 not work, $i 2 added extra space,
> are there someway to handle the $i2 situation?
The bash documentation says:
${parameter}
The value of parameter is substituted. The braces are required
when parameter is a positional parameter with more than one
digit, or when parameter is followed by a character which is not
to be interpreted as part of its name.
So use curlies to separate the variable name part from the following
non-variable part.
$ v=foo
$ echo ${v}bar
foobar
And in your case you would use something like this:
printf "=PEARSON(B2:B43,${i}2:$i 43) "
Bob