How to pass current date to a curl query using shell script?

后端 未结 3 1304
清歌不尽
清歌不尽 2021-02-14 13:21

I am inserting data to a elastic search using CURL, it works fine when i insert with a fixed data. I am trying to Get Current DateTime and assign to a variable and use with the

3条回答
  •  一整个雨季
    2021-02-14 14:17

    You can do it like this:

    DATE_ISO=$(date +"%Y-%m-%dT%H:%M:%S")
    ...
    curl -XPUT 'http://localhost:9200/nondomain_order/orders/'+$number+'' -d '{
    ...
       "CreateDate": "'"$DATE_ISO"'",
    ...
    }'
    

提交回复
热议问题