I want to put my program’s output into a file. I keyed in the following :
./prog > log 2>&1
But there is nothing in the file “log”. I am using the Ubuntu 11.10 and the default shell is bash.
Anybody know the cause of this AND how I can debug this?
There are many possible causes:
logfile while you try to redirect into it with truncation (see Why doesn't "sort file1 > file1" work?)fflushor outputstd::flushif using C++ I/O stream etc.Your best bet is to run this application under a debugger (like
gdb) or usestraceorptrace(or both) and see what the program is doing. I mean, really, output redirection works for the last like 40 years, so the problem must be somewhere else.