【问题标题】:How to append a file with the existing one using CURL?如何使用 CURL 将文件附加到现有文件?
【发布时间】:2017-03-14 12:42:49
【问题描述】:

我在整个网络上进行了搜索,但找不到任何有用的信息。使用 CURL,我想将内容附加到已经存在并命名为 test.pls 的文件中。谁能告诉我如何使用 curl 来做到这一点。我试过的命令是

curl http://192.99.8.170:8098/stream --output test.pls

curl -K --output test.pls http://192.99.8.170:8098/stream

curl -a  --output test.pls http://192.99.8.170:8098/stream

但以上所有内容都是从头开始创建文件。他们不保留文件的初始内容,谁能帮帮我!

【问题讨论】:

  • 你试过curl http://192.99.8.170:8098/stream >> test.pls吗?
  • 啊太棒了!它的工作,谢谢!我重新检查了其他文件并且它工作正常。

标签: shell curl append


【解决方案1】:

使用 shell 的附加输出重定向 (>>) 而不是 curl 的 --output 选项。

curl http://192.99.8.170:8098/stream >> test.pls

【讨论】:

    【解决方案2】:

    一个更简单、更干净的方法如下:

    curl -sS https://address.to.file.txt >> file-name.txt
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-05
      • 2019-07-24
      • 1970-01-01
      • 2020-05-02
      • 1970-01-01
      • 2014-08-01
      • 1970-01-01
      • 2020-05-16
      相关资源
      最近更新 更多