zoukankan      html  css  js  c++  java
  • Shell parameter expansion

    使用sh写一些小型的脚本会使工作更加简单。有部分内容可能大家都比較陌生(至少我是这样)。

    就是变量有关的參数展开,以下就是一些简单的描写叙述和使用方法。能够使代码更加简洁

    展开运算符

    替换运算

    ${varname:-word} var exist & not null,return value ,else return word

    ${varname:=word}  var exist & not null,return value, else varname=word & return $varname

    ${varname:?message} var exist & not null,return value, else show message & if not define exit


    #test variable is or not exist

    ${varname:+word} if exist & not null ,return word, else return null


    (:)is optional


    匹配运算

    ${variable#pattern}

    ${variable##pattern}

    ${variable%pattern}

    ${variable%%pattern}

    # % is from left or right




  • 相关阅读:
    python3第六天
    python3第五天
    python3第四天
    python3 第三天
    python3第二天
    python3(2)
    python3(1)
    网络通信 & 初识socket
    python中包的语法
    模块语法
  • 原文地址:https://www.cnblogs.com/jzssuanfa/p/6784707.html
Copyright © 2011-2022 走看看