0

Error is in stroke:

printf "%15s\t%5d\t%5.2f%%\n" bc <<< "scale=2; 100 * $mac / $totals" > result

i cant understand it. Before bc and after $totals" is sign `

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
user1925442
  • 45
  • 2
  • 2
  • 6

2 Answers2

1
printf "%15s\t%5d\t%5.2f%%\n" $(bc <<< "scale=2; 100 * $mac / $totals") > result
                              ^^                                      ^
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
1

You aren't calling bc. The string bc is simply the first of 3 expected arguments to printf. When your shell recognizes <<< as a redirection operator where the 2nd argument to printf should be, it throws an error.

I suspect you want $(bc <<< "scale=2; 100 * $mac / $totals"), but it's not clear which argument to printf that should be (although, it looks like it should be the third, for the %5.2f placeholder), or what the other two arguments should be.

chepner
  • 497,756
  • 71
  • 530
  • 681