Sample Header Ad - 728x90

Linux Restricted Bash shell perform arithmetic calculations

-3 votes
2 answers
153 views
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.
Asked by satsensort (87 rep)
Jan 4, 2022, 04:55 PM
Last activity: Jan 4, 2022, 05:46 PM