Redirection using file descriptors

Syntax

command >&n

Send the output from command to the file descriptor n or /dev/fd/n.

command m>&n
command >&-

Close the standard input.

command <&n

Take the input for command from the file descriptor n or /dev/fd/n.

command m<&n
command <&-

Close the standard output.

command <&n-
command >&n-

Example

# redirect the standard output to the standard error

echo "Error: see logfile." 1>&2

2020-07-14