作为一个单独的工具,它工作得很好:

curl "someURL"
curl -o - "someURL"

但这在流水线上行不通:

curl "someURL" | tr -d '\n'
curl -o - "someURL" | tr -d '\n'

它返回:

(23) Failed writing body

管道cURL输出的问题是什么?如何缓冲整个cURL输出,然后处理它?


当前回答

对于完整性和将来的搜索:

这取决于cURL如何管理缓冲区,缓冲区使用-N选项禁用输出流。

例子: curl -s -N "URL" | grep -q欢迎

其他回答

在我的情况下,服务器耗尽了磁盘空间。

用df -k检查它。

当我尝试两次通过tac进行管道处理时,我被提醒磁盘空间不足,如另一个答案:https://stackoverflow.com/a/28879552/336694中所描述的那样。它向我显示了错误消息写错误:设备上没有剩余空间。

对于完整性和将来的搜索:

这取决于cURL如何管理缓冲区,缓冲区使用-N选项禁用输出流。

例子: curl -s -N "URL" | grep -q欢迎

用sudo尝试命令对我有用。例如:

sudo curl -O -k 'https url here'

注意:-O(这是大写o,不是零)& -k https url。

因为我自己的打字错误,我也有同样的问题:

# fails because of reasons mentioned above
curl -I -fail https://www.google.com | echo $? 
curl: (23) Failed writing body

# success
curl -I -fail https://www.google.com || echo $?

我得到这个错误试图使用jq时,我没有安装jq。所以…如果您尝试使用jq,请确保已安装jq。