#!/bin/sh
current=`date "+%Y-%m-%d %H:%M:%S"`
timeStamp=`date -d "$current" +%s`
#将current转换为时间戳,精确到毫秒
currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000))
echo "$current $i $currentTimeStamp"
param1='[{"k1":"v1","k2":"v2","timestamp":'
param2=',"k3":"v3","k4":3.0}]'
paramall="$param1 $currentTimeStamp $param2"
echo $paramall
curl -H "Content-Type:application/json" -X POST -d "$paramall" 'http://www.baidu.com'
- 定义json需要用单引号包住
- curl传入json变量需要用双引号包住
- 两个单引号之间的字符串是不可变的