cancel
Showing results for 
Search instead for 
Did you mean: 

redirection question?

SOLVED
Go to solution
eugene_6
Advisor

redirection question?


let's say i run a program "a.out"
================
a.out outputfile
================
can i store input(from inputfile)
in outputfile ?

for example
$ a.out > outputfile
--------------------
input a number:
332 #user input
input second number:
232 #user input
result is:
332+232=564
--------------------
can i redirect 332 & 232 (user input) to outputfile along with standard output?

thx

Eugene Kim
3 REPLIES
Stefan Saliba
Trusted Contributor
Solution

Re: redirection question?

yes you can try using "2>&1" instead of ">" when you re-direct


good luck

stefan
Paul R. Dittrich
Esteemed Contributor

Re: redirection question?

A different method you might want to look at is "tee".

Do a "man tee" and see if you like it.

HTH,
Paul
eugene_6
Advisor

Re: redirection question?

hi..

i don't think i made my question clear --;

let's say
------------------
$ neg.out
input number:
300
result is -300
------------------
neg.out is waiting for user input
from stdin..
and user inputs "300"
then neg.out gives me
"result is -300"

here's my question
when i redirect output to file
as..
---------------------
$ neg.out >outputfile
input number:
300 #user input

$ cat outputfile
input number:
result is -300
---------------------
can i store the user input "300" in the outputfile too?
so that when i
----------------------
$cat outputfile
input number:
300
result is -300
----------------------

was your answer for this question? --;
if it was, can u give me a little more explanation about how to do it?

thx

Eugene Kim