{"id":60,"description":"bash: arithmetic with expr","tags":["bash","shell","programming"],"contents":["expr 2 + 7 # evaluate the expression and writes to standard output. Spaces are needed between the tokens","# multiplication operator * need to be escaped","expr 7 * 3 # results in syntax error","expr 7 \\* 3 # evaluates to 21","e=$(expr 2 + 7) # evaluate the expression and assign. Similar to $((expression))","expr 2+7 # prints the expression as is without evaluating","expr \"2 + 7\" # prints the expression as is without evaluating even with quotes"]}