LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why need double braces to evaluate a math operation? (https://www.linuxquestions.org/questions/linux-newbie-8/why-need-double-braces-to-evaluate-a-math-operation-931098/)

johnifanx98 02-24-2012 01:43 PM

Why need double braces to evaluate a math operation?
 
like
Code:

echo $(($1*$2))
I know
Code:

echo $($1*$2)
not work...

colucix 02-24-2012 02:05 PM

Because the $(...) syntax is for command substitution and bash cannot distinguish them otherwise.

suicidaleggroll 02-24-2012 02:23 PM

$((op)) tells it to do a math operation
$(op) tells it to execute that command as if it was typed on the command line, ie: $(date +%s)

johnifanx98 02-24-2012 10:20 PM

Quote:

Originally Posted by suicidaleggroll (Post 4611244)
$((op)) tells it to do a math operation
$(op) tells it to execute that command as if it was typed on the command line, ie: $(date +%s)

I like this one. Is there a manual to check this, like "help [["?

grail 02-24-2012 10:33 PM

Try checking out man bash


All times are GMT -5. The time now is 11:26 PM.