O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.7. File redirection

When issuing commands, you can specify where you want the standard input, output and errors to go, and to be able to do this you need to do a bit of redirection. A combination of the most useful redirections with corresponding file descriptors is shown in Table 5.1.

When using standard error in redirection, you must use a file descriptor, but for standard input and output this is optional. Table 5.1 shows both methods for completeness.

Table 5.1. Common file redirection commands
Command > filename Send standard output to a new filename
Command >> filename Send standard output to filename (appended)
Command 1 > filename Send standard output to filename
Command > filename 2>&1 Send all output (including errors) to filename ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required