Some Linux Tricks
Visited 148 times, 1 so far today Dedicated Server Hosting, Linux VPS Hosting, Plesk For Linux, VPS hosting, linux Add comments
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














Recent Comments