linux - Add and Multiply numbers using shell script -


i'm learning shell scripting, i'm trying write small script adds , multi number shown below amt value not display

value=212 amt=`expr "( $value * 2 + ( $value * 2 * .075 ) ) " | bc` echo $amt 

your given code works fine, intend suggest improvements:

  1. use $(...) instead of backticks.
  2. replace expr echo.

example:

value=212 amt=$(echo "( $value * 2 + ( $value * 2 * .075 ) ) " | bc) echo $amt 

output:

455.800 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -