# Add single quotation to curl xpost in shell script

**URL:** <https://discuss.elastic.co/t/add-single-quotation-to-curl-xpost-in-shell-script/149034>\
**Category:** Elasticsearch\
**Created:** [September 19, 2018, 1:11am UTC](https://discuss.elastic.co/t/add-single-quotation-to-curl-xpost-in-shell-script/149034 "2018-09-19T01:11:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nayun\_oh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nayun_oh/32/46442_2.png) [@nayun\_oh](https://discuss.elastic.co/u/nayun_oh)\
**Post date:** [September 19, 2018, 1:11am UTC](https://discuss.elastic.co/t/add-single-quotation-to-curl-xpost-in-shell-script/149034/1 "2018-09-19T01:11:38Z")

</div>

I add this code in my shell script. But every time I add single quotation in painless( 'hello' )  
It keeps giving me errors. I don't know what is wrong with my code. I hope you will be able to help with this. Thank you in advance.

cmd="curl -XPOST '[http://localhost:9200/\_reindex](http://localhost:9200/_reindex)' -H 'Content-Type: application/json'  
-d '  
{  
"source": {  
"index": "aaa"  
},  
"dest": {  
"index": "bbb"  
},  
"script": {  
"inline": "ctx.\_source.col1 = ctx.\_source.col2 + 'hello' ",  
"lang": "painless"  
}

}'  
"  
eval $cmd

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 20, 2018, 12:18pm UTC](https://discuss.elastic.co/t/add-single-quotation-to-curl-xpost-in-shell-script/149034/2 "2018-09-20T12:18:10Z")

</div>

this is more of a shell escaping question rather than an elasticsearch question.

As you havent mentioned your shell, the most important part is to read about escaping roles for your shell. Sometimes it is as easy as prepending the tick with a backslash, like `\'` when doing the quotation. You could also use double tickes and escape them properly, so that those are JSON escaped when being sent to Elasticsearch.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 18, 2018, 12:18pm UTC](https://discuss.elastic.co/t/add-single-quotation-to-curl-xpost-in-shell-script/149034/3 "2018-10-18T12:18:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
