How can I save a copy of my program's output?
There are two ways to capture your program's output in a file.
The first way is to use "output redirection". If your program does not require you to type in data at the keyboard, you can redirect the output from the program into a file by typing this command:
executable_name > log.txt
where "executable_name" is the name of your program. This method puts output into a file named 'log.txt'; it does not display anything (except errors) on your screen.
If you need to enter data from the keyboard, you probably want to use the
"script" command, which stores a script of your terminal session, recording both input and output, exactly as you typed it, including control characters (ie: carriage returns). To begin capturing input and output, simply type "script" followed by the name of the file you wish to save the output to:
Script started, file is myoutput.txt
You'll then get your shell prompt back (a new shell is started). After you run your commands, exit the shell by typing "exit" or pressing Ctrl-D.
Script done, file is myoutput.txt
You can then examine the output of the file using any text editor.