redirection

Bash duplicate stderr from stdout

Copies the current descriptor 1 destination onto descriptor 2; later redirections of 1 do not move 2.

Formal Syntax & Structure

bash syntaxbash
2>&1

Return Value

redirection effect

Copies the current descriptor 1 destination onto descriptor 2; later redirections of 1 do not move 2.

Working Example

Example Snippetbash
report() { printf 'out\n'; printf 'err\n' >&2; }report > both.log 2>&1printf 'file:\n'; cat both.log
Bash Reference