Redirecting input and output

You can override the behavior of commands that read from, or write to, stdin, stdout, and stderr.

Most commands:

Sometimes you want to override this behavior.

If you want a process to: Use this symbol:
Read from a file, or another device (input redirection) <
Write stdout to a file (output redirection) >
Write stdout to a file, appending to the file's contents (output append) >>

For example, the ls command lists the files in a directory. If you want to redirect to output of ls to a file called filelist, enter:

ls > filelist

You can specify a file descriptor for the above redirections. For example, if you don't want to display any error messages, redirect stderr to dev/null (a special file, also known as the bit bucket, that swallows any data written to it and returns end-of-file when read from):

my_command 2> /dev/null

For more information, see Input/output redirection in the entry for ksh in the Utilities Reference.