tags:

views:

51

answers:

3

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.

+1  A: 

add 2 3 > something.txt

popester
A: 

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
stefanB
This is redirection, *not* piping.
pavium
Typo, fixed .............
stefanB
+5  A: 

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.

Paolo Tedesco