Understanding Input and Output
So far, you've seen two methods for displaying the output from your scripts:
- Displaying output on the monitor screen
- Redirecting output to a file
Both methods produced an all-or-nothing approach to data output. There are times, however, when it would be nice to display some data on the monitor and other data in a file. For these instances, it comes in handy to know how Linux handles input and output so you can get your script output to the right place.
The following sections describe how to use the standard Linux input and output system to your advantage, to help direct script output to specific locations.
Standard file descriptors
The Linux system handles every object as a file. This includes the input and output process. Linux identifies each file object using a file descriptor. The file descriptor is a non-negative integer that uniquely identifies open files in a session. Each process is allowed to have up to nine open file descriptors at a time...