zoukankan      html  css  js  c++  java
  • shell 字符串比较

    #! /bin/bash

    name=`basename $0`
    echo $name=======================================
    if [ "$name" == "addem" ]
    then
    echo $name+++++++++++++++
    total=$[ $1 + $2 ]
    elif [ "$name" == "multiem" ]
    then
    echo $name########################
    total=$(( $1 * $2 ))
    fi
    echo the calcuated value is $total

    ====================== 华丽的分割线=========================================

    昨天晚上写的总有问题,以为脚本有问题,今天重新测试了下,发现木有问题,难道晚上头脑易混乱…………………………

    #! /bin/bash
    name=`basename $0`
    echo $name===========================================
    if [ $name = "addem" ]
    then
    echo $name+++++++++++++++++++++++
    total=$[ $1 + $2 ]
    elif [ $name = "multiem" ]
    then
    echo $name###########################
    total=$(( $1 * $2 ))
    fi
    echo the total result is $total

    #! /bin/bash
    name=`basename $0`
    echo $name===========================================
    if [ "$name" == "addem" ]
    then
    echo $name+++++++++++++++++++++++
    total=$[ $1 + $2 ]
    elif [ "$name" == "multiem" ]
    then
    echo $name###########################
    total=$(( $1 * $2 ))
    fi
    echo the total result is $total

    =和== 等效

     

  • 相关阅读:
    MultipartFile(文件的上传)
    JSONObject.fromObject--JSON与对象的转换
    Map集合与转化
    java读取excel文件
    Java中的Arrays类使用详解
    Arrays 类的 binarySearch() 数组查询方法详解
    JDK8 特性详解
    关于Java堆、栈和常量池的详解
    深入java final关键字
    杯酒人生
  • 原文地址:https://www.cnblogs.com/loongqiang/p/3454934.html
Copyright © 2011-2022 走看看