Article 5H3CA how to let script recognize parenthesis input on the command line?

how to let script recognize parenthesis input on the command line?

by
bsmile
from LinuxQuestions.org on (#5H3CA)
I am writing a simple script to let bc evaluate simple math expressions and output on the screen. I write down a file called mybc as

Code:#!/bin/sh

express=$1

echo "scale=6; $express" | bcand run it on the command line as

mybc sqrt(6.0)

and get the following error message

bash: syntax error near unexpected token `('

If I run the following on the command line as

mybc sqrt\(6.0\)

It can work correctly. But I hope mybc can just run as the first way. I searched a bit and landed on the following link

https://stackoverflow.com/questions/...-the-command-l

but it seems to help with parenthesis used within the script, and thus does not help.latest?d=yIl2AUoC8zA latest?i=jVgCdhxSQ3w:vr1D0iV1ih4:F7zBnMy latest?i=jVgCdhxSQ3w:vr1D0iV1ih4:V_sGLiP latest?d=qj6IDK7rITs latest?i=jVgCdhxSQ3w:vr1D0iV1ih4:gIN9vFwjVgCdhxSQ3w
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments