Book Image

Linux Shell Scripting Essentials

Book Image

Linux Shell Scripting Essentials

Overview of this book

Table of Contents (15 chapters)
Linux Shell Scripting Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Redirecting the standard I/O and error streams


We have an option to redirect standard input, output, and errors, for example, to a file, another command, intended stream, and so on. Redirection is useful in different ways. For example, I have a bash script whose output and errors are displayed on a standard output—that is, terminal. We can avoid mixing an error and output by redirecting one of them or both to a file. Different operators are used for redirection. The following table shows some of operators used for redirection, along with its description:

Operator

Description

>

This redirects a standard output to a file

>>

This appends a standard output to a file

<

This redirects a standard input from a file

>&

This redirects a standard output and error to a file

>>&

This appends a standard output and error to a file

|

This redirects an output to another command

Redirecting standard output

An output of a program or command can be redirected...