终端输入多行

时间:2019-01-08 13:09:22

标签: bash shell terminal zsh

编辑:解决,错字。聪明的我\ +“”有效(反斜杠和空格有效)

我知道之前已经有人问过这个问题,我想参考this帖子,其中-对我来说正确的答案-使用反斜杠。

不幸的是,我不知道如何。我尝试了多行curl请求,以下两个示例使我在此处发布帖子,因为它们都不起作用:

接一:

curl -X PUT localhost:8080/employees/4\ 
-H 'Content-type:application/json'\
-d '{"name:" "Smurf", "role": "Blueman"}'
{"timestamp":"2019-01-08T13:06:36.563+0000","status":400,"error":"Bad Request","message":"Required request body is missing: payroll.Employee payroll.EmployeeController.replaceEmployee(payroll.Employee,java.lang.Long)","path":"/employees/4-H"}curl: (3) Port number ended with 'a'

[1/2]: "name:" "Smurf" --> <stdout>
--_curl_--"name:" "Smurf"
curl: (3) Port number ended with '"'

[2/2]:  "role": "Blueman" --> <stdout>
--_curl_-- "role": "Blueman"
curl: (3) Port number ended with ' '

所以我想,在使用反斜杠之前添加空间可以解决此问题。 但是后来发生了:

curl -X PUT localhost:8080/employees/4 \
-H 'Content-type:application/json' \
-d '{"name:" "Smurf", "role": "Blueman"}'
{"timestamp":"2019-01-08T13:07:32.204+0000","status":400,"error":"Bad Request","message":"JSON parse error: Unexpected character ('\"' (code 34)): was expecting a colon to separate field name and value; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('\"' (code 34)): was expecting a colon to separate field name and value\n at [Source: (PushbackInputStream); line: 1, column: 11]","path":"/employees/4"}% 

所以现在它不接受\作为换行符,但是尝试拦截它。
我想念什么?

1 个答案:

答案 0 :(得分:2)

您有错字。尝试:

curl -X PUT localhost:8080/employees/4 \
-H 'Content-type:application/json' \
-d '{"name": "Smurf", "role": "Blueman"}'

错误消息告诉您确切的问题所在。