0

I've got problem with * operator. I've tried to write a script, that take 3 paremater, first two are number (any type), the third is operator then print out result of the expression. Everything've work fine except with * operator. I've got error "(standard_in) 1: syntax error"

Here's my code.

if [[ $3 == / &&  $2 == 0 ]]
then
    echo "divide by 0"
    exit 1
fi
result=$(echo "$1$3$2"|bc -l)
echo "result: $result"

I print '$3' and got list file of parent directory, so the script understand that '*' is the list file.

So, what can i do with this issue? Thank,

Yukoo
  • 3
  • 1

1 Answers1

0

You can pass the asterisk as a string with ./myscript '*' - in that case it's not expanded by your shell.

Knut
  • 1,792
  • 13
  • 9