I have to variables and I want to find the value of one divided by the other. What commands should I use to do this?
While you can't use floating point division in Bash you can use fixed point division. All that you need to do is multiply your integers by a power of 10 and then divide off the integer part and use a modulo operation to get the fractional part.
They all can be accessed using the key combination Ctrl + Alt + FN#Console. For example, the Console #3 is accessed by pressing Ctrl + Alt + F3. Note The Console #7 is usually allocated to the graphical environment (Xorg, etc.). If you are running a desktop environment, you may want to use a terminal emulator instead.
In the bash shell, surround arithmetic expressions with $(( ... ))
$ echo $(( 7 / 3 )) 2
Although I think you are limited to integers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With