Contents
Is Dev a tty?
/dev/tty stands for the controlling terminal (if any) for the current process. To find out which tty’s are attached to which processes use the “ps -a” command at the shell prompt (command line). Look at the “tty” column. For the shell process you’re in, /dev/tty is the terminal you are now using.
What is the difference between redirect and piping to the tee command?
Redirection is (mostly) for files (you redirect streams to/from files). Piping is for processes: you pipe (redirect) streams from one process to another. Essentially what you really do is “connect” one standard stream (usually stdout ) of one process to standard stream of another process (usually stdin ) via pipe.
How does redirection work on a command line?
On a command line, redirection is the process of using the input/output of a file or command to use it as an input for another file. It is similar but different from pipes, as it allows reading/writing from files instead of only commands. Redirection can be done by using the operators > and >>.
How is a here document redirected in Bash?
A here-document is an input redirection using source data specified directly at the command line (or in the script), no “external” source. The redirection-operator << is used together with a tag TAG that’s used to mark the end of input later:
How to assign a file descriptor to a redirection?
Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form { varname }. In this case, for each redirection operator except >&- and <&-, the shell will allocate a file descriptor greater than 10 and assign it to { varname }.
How to redirect stderr away from the terminal?
Relatively easy: 2>&1 redirects stderr away from the terminal to the target for stdout: the terminal (again…) What remains? stdout goes to /dev/null, stderr still (or better: “again”) goes to the terminal.