Arithmetic operation in bash script, multiply by decimal number, how?
by postcd from LinuxQuestions.org on (#5KK3V)
GNU bash, version 5.1.8(1)
How can i please do this in a bash script, i want to multiply certain number by decimal number 1.5
Non working attempts:
1)
Code:result=$(( $number * 1.5 |bc -l ))
^---------------^ SC2004: $/${} is unnecessary on arithmetic variables.
^-^ SC2079: (( )) doesn't support decimals. Use bc or awk.
^-- SC2154: bc is referenced but not assigned (for output from commands, use "$(bc ...)" ).
^-- SC2154: l is referenced but not assigned.
Code:2)
```
result=$(( $number * 1,5 ))
^---------------^ SC2004: $/${} is unnecessary on arithmetic variables.3)
Code:#!/bin/bash
number=3456
result=$( echo "$number*1.5"|bc )
echo "$result"output is decimal (5184.0) which i do not want, i want whole numbers only result
How can i please do this in a bash script, i want to multiply certain number by decimal number 1.5
Non working attempts:
1)
Code:result=$(( $number * 1.5 |bc -l ))
^---------------^ SC2004: $/${} is unnecessary on arithmetic variables.
^-^ SC2079: (( )) doesn't support decimals. Use bc or awk.
^-- SC2154: bc is referenced but not assigned (for output from commands, use "$(bc ...)" ).
^-- SC2154: l is referenced but not assigned.
Code:2)
```
result=$(( $number * 1,5 ))
^---------------^ SC2004: $/${} is unnecessary on arithmetic variables.3)
Code:#!/bin/bash
number=3456
result=$( echo "$number*1.5"|bc )
echo "$result"output is decimal (5184.0) which i do not want, i want whole numbers only result