СÀ¶ÊÓƵ

print friendly version

Questions and answers

236
How do I send my program output to a file on a UNIX system?


The commands described below need to be entered while logged in to the Unix server.   Normally you'll see a prompt ending with $ when the command interpreter (or shell) is ready for another command.

Use the command sequence

command  >  filename

This makes command send its output to filename.

To append output to an existing file, use

command >> filename

For example, to list of all your files, storing the list in a file called files.txt, give the command

ls -lt   >   files.txt

This technique is called redirection.

Help us to improve this answer

Please suggest an improvement
(login needed, link opens in new window)

Your views are welcome and will help other readers of this page.

Categories

This is question number 236, which appears in the following categories:

Created by Andy Clews on 27 July 2001 and last updated by Andy Clews on 4 August 2015