I have a shell script to calculate cpu and memory resources in a vm. For one task, I would like to perform mathematical calculations in a rbash shell. Could you please guide me the possible workarounds.
I have been trying like
echo $a / 1024 | bc
I'm trying the below substitution and getting the below error. Can you please advise me
Both the variables have decimal values as well. Like 0.4, 10.0 and would need to subtract and get the values
for used_cores in `echo (( $config_cpu - $free_cpu )) | grep [0-9] || echo NA`
do
echo $used_cores
done
Error:
bash: command substitution: line 12: syntax error near unexpected token `('
The question seems to be different from the reference question. Can you please consider this question.