Playing with file descriptors and redirection
File descriptors are integers that are associated with file input and output. They keep track of opened files. The best-known file descriptors are
. We can redirect the contents of one file descriptor to another. The following recipe will give examples on how to manipulate and redirect with file descriptors.
While writing scripts we use standard input (
stdin), standard output (
stdout), and standard error (
stderr) frequently. Redirection of output to a file by filtering the contents is one of the essential things we need to perform. While a command outputs some text, it can be either an error or an output (non-error) message. We cannot distinguish whether it is ...