20. Bash Shell - IO Redirection
Contents
With the IO redirection feature, we can easily manipulate the input and output of files or other information.
Standard Output
The standard output stream is usually used to print the output of a program to a file, its file descriptor is 1.
Output Text to a File
|
|

Output text to fresh_file
Output Result to a File
|
|

Output result to dir_list_file
Append Text to a File
|
|

Append text to fresh_file
Append Result to a File
|
|

Append result to dir_list_file
Standard Input
Standard input streams are usually used to print the contents of a file to a screen, its file descriptor is 0.
Read Text from a File
|
|

Read text from fresh_file
Copy Text from a File to Another File
|
|

Copy text from fresh_file to new_fresh_file
Multi-line Text to a File Using Here Documents
|
|

Input here documents to new_here_document_file
Standard Error
Standard error streams are typically used to print error content from the output of a program to a file, its file descriptor is 2.
Redirects Error Messages to a File
|
|

Redirects error messages to error_log file
Standard error streams are typically used to print error content from the output of a program to a file, its file descriptor is 2.
Suppress the Error Messages
|
|

Redirects error messages to /dev/null
Standard error streams are typically used to print error content from the output of a program to a file, its file descriptor is 2.
Show Error Messages and Output Standard Results to a File
|
|

Show error messages on screen and output standard results to a file
|
|

Show error messages on screen and output standard results to a file
References 3.6 Redirections
Author Dong Chen
LastMod Thu Feb 21 2019