writing data from a program to a file
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开发者_StackOverflow社区
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.
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.
add 1 2 | echo
What you are asking about here is output redirection: you should use
add 1 2 > add.data
to create a new file with your output (if existing will be overwritten), and
add 1 2 >> add.data
to create a new one or append to an existing.
add 2 3 > something.txt
This will redirect output into a file, recreates the file every time
add 1 2 > add.data
This will append to the end of the file
add 1 2 >> add.data
精彩评论