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

后端 未结 3 1394
清歌不尽
清歌不尽 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 13:56

    Rather than playing with quotes inside quotes I would suggest using here-doc to get rid of all magic quoting. Use your curl like this:

    number=10
    dt="$(date --iso-8601=seconds)"
    
    curl -XPUT 'http://localhost:9200/nondomain_order/orders/'$number -d@- <

提交回复
热议问题