linux Shell脚本截取字符串
例如截取日志信息中的json类型的输入信息:

脚本如下:
#!/bin/sh
IFS=""
testfile=$1
while read -r line
do
echo $line
test1=${line##*'签名验证错误'}
test1=${test1%currentid*}
echo $test1
##res_code=`echo $test1 | python -c 'import sys, json; print(json.load(sys.stdin)['order_complete_time'])'`
##echo $res_code
##exit
##temp= echo $line | cut -d "\"" -f 19
##if [ -n "$temp" ]; then
## echo $temp
##fi
done < $testfile
posted on 2021-07-27 13:54 1450811640 阅读(104) 评论(0) 收藏 举报
浙公网安备 33010602011771号