Access Keys:
Skip to content (Access Key - 0)

How to capture a copy of the output for printing

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:

a.out > output.txt

This method puts output into a file named 'output.txt'; it does not display anything on your screen.

If you need to enter data from the keyboard, you probably want to use the 'script' command. Script makes a copy of everything that is printed on your terminal. To use 'script', first type this command:

script output.txt

The machine will respond:

Script started, file is output.txt

Then run your program normally. When the program is done, type:


The machine will respond:

Script done, file is output.txt

You can use the more command to view the file on your terminal screen, or you can print the output file on a printer as you would any other file.

IS&T Contributions

Documentation and information provided by IS&T staff members

Last Modified:

May 13, 2012

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
olc-fortran olc-fortran Delete
copy copy Delete
output output Delete
printing printing Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
This product/service is:
Easy to use
Difficult to use

This article is:
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki