redirection

Bash Standard error to a file

Connects descriptor 2 to a file, creating or truncating it. Normal output is unaffected.

Formal Syntax & Structure

bash syntaxbash
command 2> file

Return Value

behavior

Connects descriptor 2 to a file, creating or truncating it. Normal output is unaffected.

Working Example

Example Snippetbash
bash -c 'printf "%s\n" note >&2' 2> diag.txtcat diag.txt
Bash Reference