如何在curl中发送单引号和特殊字符

时间:2015-10-15 08:29:41

标签: curl elasticsearch

我正在尝试卷曲,这就像:

curl -XPOST 'http://localhost:9200/market/products/' -d '{
    "description": \"If you and your husband or boyfriend like to wear things that match; and he wears frame model 189812 or 189832; or the Unisex frame models 187821 or 187812; you've got to get this full-rim; round; medium-size; faux-wood; hypoallergenic acetate Women's eyeglasses frame. The male and female versions of these glasses are similar; although these are actually a little bigger than the male model. (We're talking about your guy; so don't start thinking about male models; unless he is one.) One version is brown; the other is purple; and the two of you will look adorable in your matching glasses. If you're single; you won't be for long (if that's your desire); because you'll look adorable in these glasses all by yourself!\"" }'

现在我的问题是描述字段中的特殊字符。任何人都可以建议我该怎么做。

由于

1 个答案:

答案 0 :(得分:0)

您需要将所有单引号加倍(即you''ll而不是you'll)并删除说明字段中的第一个反斜杠,如下所示:

curl -XPOST 'http://localhost:9200/market/products/' -d '{    "description": "If you and your husband or boyfriend like to wear things that match; and he wears frame model 189812 or 189832; or the Unisex frame models 187821 or 187812; you''ve got to get this full-rim; round; medium-size; faux-wood; hypoallergenic acetate Women''s eyeglasses frame. The male and female versions of these glasses are similar; although these are actually a little bigger than the male model. (We''re talking about your guy; so don''t start thinking about male models; unless he is one.) One version is brown; the other is purple; and the two of you will look adorable in your matching glasses. If you''re single; you won''t be for long (if that''s your desire); because you''ll look adorable in these glasses all by yourself!\"" }'
                                                                             ^
                                                                             |
                                                           remove the backslash here