I want to print * character in echo. Current behaviour prints my script filename:
result="multiply $1 * $2 is = $[$1*$2]"
myfile.sh 2 5 prints:
multiply 2 myfile.sh 5 is 10
I've read similar problem and answers and my approaches were:
result="multiply $1 '*' $2 is = $[$1*$2]"
which gave:
multiply 2 '*' 5 is 10
So another approach was to make a variable:
helper="*"
result="multiply $1 "$helper" $2 is = $[$1*$2]"
but the result was the same:
multiply 2 myfile.sh 5 is 10
What is the problem?
Full code:
function multiply {
result="multiply $1 * $2 is = $[$1*$2]"
}
multiply $1 $2
echo $result
I tried escaping the asterisk with * but it prints:
multiply 2 \* 5 is 10