Created: 2023-07-22 22:25
Status: #concept
Subject: Programming System Administration
Tags: Bash CLI stdout stdin
sterr
The stardard stream where errors are logged out to avoid conflicts with stdout.
- its file descriptor is
2
.
$ ls /non-existent/directory > test.txt
ls: cannot access /fake/directory: No such file or directory
$ cat test.txt # outputs nothing
We have to redirect it with the
2>
Bash Stream Redirection operator.
- if we want to redirect or append both
stdout
andstderr
, we use&>
or&>>
, respectively.
$ ls /fake/directory 2> test.txt
$ cat test.txt
ls: cannot access '/fake/directory': No such file or directory