Automatically add newline at end of curl response body

前端 未结 4 1979
-上瘾入骨i
-上瘾入骨i 2020-12-07 07:58

If the HTTP response body for a curl request doesn\'t contain a trailing newline, I end up with this really annoying condition where the shell prompt is in the middle of the

4条回答
  •  心在旅途
    2020-12-07 08:23

    From the man file:

    To better allow script programmers to get to know about the progress of curl, the -w/--write-out option was introduced. Using this, you can specify what information from the previous transfer you want to extract.

    To display the amount of bytes downloaded together with some text and an ending newline:

    curl -w 'We downloaded %{size_download} bytes\n' www.download.com
    

    So try adding the following to your ~/.curlrc file:

    -w "\n"
    

提交回复
热议问题