Adminbuntu

Everything for the Ubuntu Server Administrator

User Tools

Site Tools


Sidebar

Server Administration


Server Applications


At the Command Line


Elsewhere


Copyright 2013 Applied Conscious Technologies, LLC

Terms of Agreement

Contact


submit to reddit

math

At the Command Line

Math

dc - the reverse polish notation calculator

Install dc with aptitude.

This is a full reverse polish notation calculator. A simple example of use:

10
10
+
p

…which results in the value of “10+10”:

20

Quick math (Calculate φ). See also bc

echo '(1 + sqrt(5))/2' | bc -l

More complex (int) e.g. This shows max FastE packet rate

echo 'pad=20; min=64; (100*10^6)/((pad+min)*8)' | bc

Python handles scientific notation

echo 'pad=20; min=64; print (100E6)/((pad+min)*8)' | python

Plot FastE packet rate vs packet size

echo 'pad=20; plot [64:1518] (100*10**6)/((pad+x)*8)' | gnuplot -persist

Base conversion (decimal to hexadecimal)

echo 'obase=16; ibase=10; 64206' | bc	

Base conversion (hex to dec) ((shell arithmetic expansion))

echo $((0x2dec))

Unit conversion (metric to imperial)

units -t '100m/9.69s' 'miles/hour'

Unit conversion (SI to IEC prefixes)

units -t '500GB' 'GiB'

Definition lookup

units -t '1 googol'

Add a column of numbers

See also add and funcpy

seq 100 | (tr '\n' +; echo 0) | bc
echo "DISPLAY=$DISPLAY xmessage cooker" | at "NOW + 30 minutes"

math.txt · Last modified: 2015/05/31 21:20 (external edit)