Skip to content
Advertisement

I’m getting errors in my shell script

MY CODE :

JavaScript

THE ERRORS :

JavaScript

Advertisement

Answer

Your code has lots of issues.

  • You were not consistent in your variable names (e.g. pp vs. PurPrice)
  • You only use $ when you want the value of a variable (not on read’s for example).
  • You can’t use strings with the integer test operators (-eq and so on).
  • You need backticks to get the output of commands you run.

Here is functional code:

JavaScript

but note that the test operators (-eq -gt etc) only work on integers (entering a price like 1.99 will cause it to fail)!

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement