Automatically add newline at end of curl response body

前端 未结 4 1969
-上瘾入骨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:35

    Use this:

    curl jsonip.com; echo 
    

    If you need grouping to feed a pipe :

    { curl jsonip.com; echo; } | tee new_file_with_newline
    

    OUTPUT

    {"ip":"x.x.x.x","about":"/about"}
    

    This is that simple ;)

    (and not limited to curl command but all commands that not finish with a newline)

提交回复
热议问题