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
stderr. We even can redirect the contents of one file descriptor to another. This recipe shows 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 an 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 (nonerror) message. We cannot distinguish whether it is output ...