0

I am trying to write a very simple script using bc.

My script is saved as cl and contains

#!/bin/bash
echo "$@" | bc

But running cl 2 * 3 gives several (standard_in) 1: syntax error lines.
Running cl 2*3 gives correct output.

I believe * is expanding to filenames due to soft quotaion. How to avoid it ?

MAKZ
  • 165
  • 14

1 Answers1

1

As always, quote or escape it.

cl 2 '*' 3
cl 2 \* 3
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358