Posts Tagged ‘addition in linux’
Some Linux Tricks
Written by AlanV on October 12, 2008 – 6:26 am -Some Linux Tricks
To do simple calculation you can use command ((…))
$ echo $(( 20 + 10 ))
30
Following are the basic math operator use in Linux.
+ perform addition
/ divide last two numbers
* perform multiplication
- perform substration
For more complex math , like floating point etc. use bc command
$ echo "scale=5; 5/3" | bc
1.66666
You can use ((…)) or bc command to convert hex values to decimal
$ echo $((0xff))
255
$ echo 'obase=10; ibase=16; FF' | bc
255
You should always use uppercase letters while using bc command
To convert decimal to hex:
$ echo 'obase=16; ibase=10; 255' | bc
FF
One of the most important command ‘units’you can use to do conversion
$ units -t '1mile' 'km'
1.609344
Hope you will enjoy this
Tags: addition in linux, conversion in linux, hexadecimal in linux, math operators in linux, unit conversion in linux
Posted in Dedicated Server Hosting, Linux VPS Hosting, Plesk For Linux, VPS hosting, linux | No Comments »





