bash 使用终端记录/保存数据流

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3019321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 22:12:00  来源:igfitidea点击:

Using terminal to record/save a data stream

bashsavedata-stream

提问by jonhurlock

I want to be able to save a data stream which i am returning using the curl command. I have tried using the cat command, and piping it the curl command, however i'm doing it wrong. The code im currently using is:

我希望能够保存我使用 curl 命令返回的数据流。我曾尝试使用 cat 命令,并将 curl 命令通过管道传递给它,但是我做错了。我目前使用的代码是:

cat > file.txt | curl http://datastream.com/data

Any help would be appreciated.

任何帮助,将不胜感激。

回答by Jim Lewis

Try:

尝试:

curl http://datastream.com/data > output_file.txt

回答by Jonathan Leffler

So, you are using 'curl' to collect data, and want to capture its output?

那么,您正在使用 'curl' 来收集数据,并想要捕获其输出?

curl http://example.com/data > file.txt

Or, indeed (from the man page):

或者,确实(来自手册页):

curl -o file.txt http://example.com/data