侧边栏壁纸
  • 累计撰写 71 篇文章
  • 累计创建 87 个标签
  • 累计收到 5 条评论

目 录CONTENT

文章目录

Shell命令echo和seed避坑

KunkkaWu
2021-11-11 / 0 评论 / 2 点赞 / 6,907 阅读 / 170 字 / 正在检测是否收录...
  1. linux和mac命令差异:echosed
function xsed() {
    system=$(uname)

    if [ "${system}" = "Linux" ]; then
        sed -i "$@"
    else
        sed -i '' "$@"
    fi
}

function xecho() {
    system=$(uname)

    if [ "${system}" = "Linux" ]; then
        echo "$@"
    else
        /bin/echo "$@"
    fi
}
  1. 从json中提取数据
password=`echo "$result" | awk -F '"Password":"' '{print $2}'| awk -F '"' '{print $1}'`
  1. 去除字符串最后一个字符
requestData=${requestData%?}
  1. sed用法
origin='"RequestId":"script01"'
placed='"RequestId":"script01","TBaaSId":"'$tbaasId'"'
sedReg="s/${origin}/${placed}/g"
xsed $sedReg $requestFileaName
  1. 发送POST请求
result=$(curl -H "Content-type: application/json" -X POST -o /dev/null -s %{http_code} -d "$data" $url)
2

评论区