将数据从程序写入文件
我正在使用Linux。假设我有一个名为 add 的程序。该程序需要两个数字。
所以如果我输入
add 1 2
答案是 3 //显而易见
什么命令会将其写入名为 add.data 的文件中,
我有点像 Linux n00b。我正在阅读有关管道的内容。谢谢。
I'm using linux. Let's say I have a program named add. The program takes two numbers.
so if I type in
add 1 2
the answer is 3 //obvious
what command will make this write out to a file named add.data
I'm kind of a linux n00b. I was reading about piping. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
管道意味着将程序的输出作为输入发送到第二个程序,第二个程序必须能够从标准输入读取数据,例如
您在这里询问的是输出重定向 :您应该使用
输出创建一个新文件(如果存在,将被覆盖),并
创建一个新文件或附加到现有文件。
Piping means sending the output of a program as input to a second, which must be able to read data from the standard input, e.g.
What you are asking about here is output redirection: you should use
to create a new file with your output (if existing will be overwritten), and
to create a new one or append to an existing.
添加 2 3 >某事.txt
add 2 3 > something.txt
这会将输出重定向到文件中,每次都重新创建该文件
这将附加到文件末尾
This will redirect output into a file, recreates the file every time
This will append to the end of the file