Multiplication on command line terminal

后端 未结 8 1920
有刺的猬
有刺的猬 2020-12-04 08:00

I\'m using a serial terminal to provide input into our lab experiment. I found that using

$ echo \"5X5\"

just returns a string of \"

8条回答
  •  不知归路
    2020-12-04 08:26

    Internal Methods

    Bash supports arithmetic expansion with $(( expression )). For example:

    $ echo $(( 5 * 5 ))
    25
    

    External Methods

    A number of utilities provide arithmetic, including bc and expr.

    $ echo '5 * 5' | /usr/bin/bc
    25
    
    $ /usr/bin/expr 5 \* 5
    25
    

提交回复
热议问题