Reputation: 66
I am writing a program and needed to momentarily silence the output. I went online and found the solution was the following:
./program > /dev/null
I now need to see the output, but have not found a way to do so. After looking for it online, I now understand that what I'm basically doing is sending the output to a 'black hole', and I believe what I need to do is send the output of the program back to the Standard Output.
I've tried:
./program >1
./program >stdout
./program /dev/null>1
./program /dev/null>stdout
but still cannot get it to work. Does anybody know a possible solution?
Upvotes: 1
Views: 559
Reputation: 965
You have stated twice that your program without redirection on the command line produces no output. So the problem is your program, not the redirection.
Also note that :
./program /dev/null>1
./program /dev/null>stdout
Both of these, which you tried, pass "/dev/null" as an argument to your application and apply redirection to that.
If you want to output to both stdout and a file using redirection you need a tee command.
You would use something like :
./program | tee mylogfiletxt
The '|' is a pipe between the output of program and the input of the tee application. tee will send a copy of its input to stdout and the file you name.
Upvotes: 0
Reputation: 18627
You can't get back the previous output. But just running the program normally will produce output to stdout
...
./program
The >
('redirection' operator), redirects the output of the program while it is running to the target file (or stream). You don't need to 'undo' or 'reverse' this in subsequent runs. Wikipedia has a great overview.
Upvotes: 6