Files
oam/knowledge base/redirect outputs.md
2025-04-29 22:42:27 +02:00

1.0 KiB

Redirect outputs

  1. TL;DR
  2. Further readings

TL;DR

Pipes are set up before the I/O redirections are interpreted.
The sequence of I/O redirections is interpreted left-to-right.

command 2>&1 >'/dev/null' | grep 'something'
command 2>'/dev/stdout' 1>'/dev/null' | grep 'something'

# Swap the standard error and standard output over, then close the spare descriptor used for the swap.
command 3>&1 1>&2 2>&3 3>&-

Further readings