shell的一些指令集合

1、去掉字符串前面几个字符

没找到直接可以去掉的指令
曲线 先去掉=号前面的会变化的部分,将剩下的不变化的用sed命令代替
echo $pss_config|awk -F '=' '{print $2}' |sed  's/PBCustmPsWebDetailSearchRsp//'

2、获取json串中某key的值:用 jq

echo $pss_config |jq -r .pss[1]

3、计算字符串中,出现的次数

echo $a | awk -F ',' '{print NF-1}'

 4、shell加减法

let count--
let currentTimeStamp=$currentTimeStamp+2000
c=$(($a+$b))

 5、乘除法

increase_degree=$(($degree_coefficient*$score))  //乘法
avg_num=$(($total_num/$pid_num))

 

6、if 并且

if [ $op_type -le 7 -a $op_type -gt 0 ]
then
    score=98
elif [ $op_type -le 13 -a $op_type -gt 7 ]
then
        score=66
fi

 

posted @ 2021-07-21 16:45  sugoi  阅读(96)  评论(0)    收藏  举报