linux ab

  1. bc 
    输出:
    bc 1.06
    Copyright 1991-1994,1997,1998,2000 Free Software Foundation,Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    9*2
    18
    

    上述命令是来做数学运算。

  2. bc -l
    输出:
    bc 1.06
    Copyright 1991-1994,1997,1998,2000 Free Software Foundation,Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    1+2
    3
    

    上述命令是求'1+2'的和。

  3. bc calc.txt
    输出:
    bc 1.06
    Copyright 1991-1994,1997,1998,2000 Free Software Foundation,Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'. 
    3
    

    'calc.txt' 这个文件有代码:1+2。 从文件输入并且显示输出结果。

    ��魏糜玫挠�算�C: bc
    如果我想要使用��蔚挠�算器呢?很容易呀!就使用 bc 即可!在�入 bc 之後, �@示出版本�Y�之後,就�M入到等待指示的�A段。如下所示:
    [root@linux ~]# bc
    bc 1.06
    Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    _<==�@���r候,游���停留在�@�e等待您的�入
    事��上,我��是『�M入到 bc �@��指令的工作�h境��中』了! 就好像我��在 Windows �e面使用『小算�P』一�樱∷�以,我��底下�L��入的�Y料, 都是在 bc 程式��中在�M行�\算的�幼鳌K�以�樱�您�入的�Y料��然就得要符合 bc 的要求才行! 在基本的 bc �算�C操作之前,先告知���使用的�\算子好了:
    • + 加法

    • - �p法

    • * 乘法

    • / 除法

    • ^ 指��

    • % �N��

    好!�我���硎褂� bc �算一些咚咚吧!
    [root@linux ~]# bc
    bc 1.06
    Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    1+2+3+4<==只有加法�r
    10
    7-8+3
    2
    10*52
    520
    10%3<==�算『�N�怠�
    1
    10^2
    100
    10/100<==�@��最奇怪!不是���是 0.1 �幔�
    0
    quit<==�x�_ bc �@���算器
    在上表��中,粗�w字表示�入的�Y料,而在每��粗�w字的底下就是�出的�Y果。 咦!每���算都�算正�_,怎�N 10/100 ���成 0 呢?�@是 因�� bc �A�O�H�出整�担�如果要�出小�迭c下位�担�那�N就必�要�绦� scale=number ,那�� number 就是小�迭c位��,例如:
    [root@linux ~]# bc
    bc 1.06
    Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    scale=3<==�]�e!就是�@�e!!
    1/3
    .333
    340/2349
    .144
    quit
    好了!就是�@�幼永玻『��蔚暮馨桑∫葬崮憧梢暂p�p��的�M行加�p乘除啦!
    MATH LIBRARY
    If bc is invoked with the -l option, a math library is preloaded and the default scale is set to 20.
    The math functions will calculate their results to the scale set at the time of their call. The math
    library defines the following functions:

    s (x) The sine of x, x is in radians. 正玄函数

    c (x) The cosine of x, x is in radians. 余玄函数

    a (x) The arctangent of x, arctangent returns radians. 反正切函数

    l (x) The natural logarithm of x. log函数(以2为底)

    e (x) The exponential function of raising e to the value x. e的指数函数

    j (n,x)
    The bessel function of integer order n of x. 贝塞尔函数


    PS: echo "scale=100; a(1)*4" | bc -l (计算圆周率)


你可能感兴趣的:(linux,操作,ab)