zoukankan      html  css  js  c++  java
  • shell expr用法

    expr 计算整数变量值

    使用方法如下:

    linux-zpycfm:/home/test/shell # s=expr 2+ 3
    -bash: 2+: command not found
    linux-zpycfm:/home/test/shell # s=expr 2+3
    -bash: 2+3: command not found
    linux-zpycfm:/home/test/shell # s=`expr 2 + 3`
    linux-zpycfm:/home/test/shell # echo $s
    5
    linux-zpycfm:/home/test/shell # `expr 2 + 3`
    -bash: 5: command not found
    linux-zpycfm:/home/test/shell # expr 2 + 3
    5
    linux-zpycfm:/home/test/shell # expr 2+3
    2+3
    linux-zpycfm:/home/test/shell # expr $s * 4
    expr: syntax error
    linux-zpycfm:/home/test/shell # expr $s * 4
    20
    linux-zpycfm:/home/test/shell # expr `expr 2 + 3` * 4
    20
    linux-zpycfm:/home/test/shell # expr 2 "*" 3
    6
    linux-zpycfm:/home/test/shell # expr 2 '*' 3
    6
    linux-zpycfm:/home/test/shell # expr 2 * 3
    expr: syntax error
    linux-zpycfm:/home/test/shell # expr 2.3 + 3.4
    expr: non-integer argument
    运算符号和参数之间要有空格分开;
    通配符号(*),在作为乘法运算符时要用、“”、‘’符号修饰
    :expr 3 * 2         expr 3 “*” 2       expr 3 ‘*’ 2 
     `(反引号)与键盘上的~同一个键上的符号 
  • 相关阅读:
    Jetty 入门
    Spring MVC 学习 之
    Spring MVC 学习 之
    Spring MVC 学习 之
    call apply 使用
    maven学习系列 之 常见问题
    SQL Server数据库partition by 与ROW_NUMBER()函数使用详解[转]
    .NET 同步 异步 委托
    常用JS方法
    通过 NPOI 生成 Excel
  • 原文地址:https://www.cnblogs.com/xingmuxin/p/8950780.html
Copyright © 2011-2022 走看看