Summary
Understanding how the bash shell handles input and output can come in handy when creating your scripts. You can manipulate both how the script receives data and how it displays data, to customize your script for any environment. You can redirect the input of a script from the standard input (STDIN
) to any file on the system. You can also redirect the output of the script from the standard output (STDOUT
) to any file on the system.
Besides the STDOUT
, you can redirect any error messages your script generates by redirecting the STDERR
output. This is accomplished by redirecting the file descriptor associated with the STDERR
output, which is file descriptor 2. You can redirect STDERR
output to the same file as the STDOUT
output or to a completely separate file. This enables you to separate normal script messages from any error messages generated by the script.
The bash shell allows you to create your own file descriptors for use in your scripts. You can create file descriptors 3...