In the Bash shell environment, every process has three files opened by default. These are standard input, display, and error. The file descriptors associated with them are 0, 1, and 2 respectively. In the Bash shell, we can assign the file descriptor to any input or output file. These are called file descriptors.
The syntax for declaring output.txt as output is as follows:
exec fd > output.txt
This command will declare the number fd as an output file descriptor.
The syntax for closing the file is as follows:
To close fd, which is 5, enter the following:
We will try to understand these concepts by writing scripts.