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?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
- Null-terminated string, opening file for reading
I still prefer using dc, which is an RPN calculator, so quick session to divide 67 by 18 with 4 digits precision would look like
Obviously, much more available: man dc
you can also use perl -e
In the bash shell, surround arithmetic expressions with
$(( ... ))
Although I think you are limited to integers.
Something else you could do using raytrace's answer. You could use the stdout of another shell call using backticks to then do some calculations. For instance I wanted to know the file size of the top 100 lines from a couple of files. The original size from
wc -c
is in bytes, I want to know kilobytes. Here's what I did:You should try to use:
In bash, if you don't need decimals in your division, you can do: