Bash redirect sdtout and stderr

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

In this article we describe how you can redirect output in the Bash in Linux sdtout and stderr. It is also commonly referred to as bash redirection or output redirection.

Bash redirection

stdout -> redirection file

program > file.txt

stderr -> redirection file

program 2> file.txt

stdout AND stderr -> redirection file

program &> file.txt

stdout -> redirection file AND stderr -> redirection file

program > file_stdout.txt 2> file_stderr.txt

stdout -> stderr

program 1>&2

stderr -> stdout

program 2>&1

Additional information


Foto Werner Fischer.jpg

Author: Werner Fischer

Werner Fischer, working in the Knowledge Transfer team at Thomas-Krenn, completed his studies of Computer and Media Security at FH Hagenberg in Austria. He is a regular speaker at many conferences like LinuxTag, OSMC, OSDC, LinuxCon, and author for various IT magazines. In his spare time he enjoys playing the piano and training for a good result at the annual Linz marathon relay.


Related articles

Hard Disk Allocation with df and du
Install logwatch
Linux Performance Analysis using kSar