AIX下的小計算器 bc

wmlm發表於2009-02-27
AIX下有時候想做個簡單計算,使用bc很方便,示例如下:[@more@]

# vmstat

System configuration: lcpu=1 mem=1024MB ent=0.10

kthr memory page faults cpu
----- ----------- ------------------------ ------------ -----------------------
r b avm fre re pi po fr sr cy in sy cs us sy id wa pc ec
1 1 136360 24579 0 0 0 0 0 0 14 197 305 2 3 95 0 0.01 5.9
# bc
4*24579
98316
4*136360
545440

man中的解釋
Examples
1 You can use the bc command as a calculator. Depending on whether you
set the scale variable and with what value, the system displays
fractional amounts. Entering:

bc
1/4

displays only 0. To set the scale variable and add a comment, enter:

scale = 1 /* Keep 1 decimal place */
1/4

The screen displays 0.2. Entering:

scale = 3 /* Keep 3 decimal places */
1/4

displays 0.250. Entering:

16+63/5

displays 28.600. Entering

(16+63)/5

displays 15.800. Entering

71/6

displays 11.833.

The bc command displays the value of each expression when you press
the Enter key, except for assignments.

When you enter the bc command expressions directly from the
keyboard, press the End-of-File (Ctrl-D) key sequence to end the bc

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/271063/viewspace-1017881/,如需轉載,請註明出處,否則將追究法律責任。

相關文章