Is it possible in linux to start a program ./program and everything it outputs gets written to a output.txt file?
1 Answer
How about ./program > /tmp/mylogfile.txt 2>&1
sending everything to the /tmp/mylogfile.txt file.
The > is a redirection of standard out (stdout) and the 2>&1 redirects standard error (stream file descriptor 2) to standard out (stream file descriptor 1)
3 Comments
user7157477
Works like a charm but it stopped printing it on the actual console, can I make it console + file?
Brian Agnew
To answer your first point, investigate 'tee'. To answer your second point, not so easy, but I'm sure there's a solution out there using the 'date' utility and perhaps a script to pipe (not redirect) into
user7157477
Wdym investigate 'tee'?