Why is setting a variable name giving me "command not found"?

I want to input a number and then add taxes and subtract discounts.

I am trying:

final_amount = $(echo "$purchase_amount+($purchase_amount * $tax)-($purchase_amount * $discount)" |bc -l)

but I’m getting:

$ . 3_purchase_amounts.sh 
final_amount: command not found

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Do not put spaces around the “=” character in the final_amount line: variable assignment in shells does not support such spaces because this would conflict with things like command_name = arg2. As you could see, the shell tried to execute a final_amount command and you got the error:

final_amount: command not found

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply