- linux和mac命令差异:
echo
和 sed
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
}
- 从json中提取数据
password=`echo "$result" | awk -F '"Password":"' '{print $2}'| awk -F '"' '{print $1}'`
- 去除字符串最后一个字符
requestData=${requestData%?}
- sed用法
origin='"RequestId":"script01"'
placed='"RequestId":"script01","TBaaSId":"'$tbaasId'"'
sedReg="s/${origin}/${placed}/g"
xsed $sedReg $requestFileaName
- 发送POST请求
result=$(curl -H "Content-type: application/json" -X POST -o /dev/null -s %{http_code} -d "$data" $url)
评论区