December 2018
Beginner
452 pages
12h 17m
English
If you were confused by the preceding example, that was probably because you misunderstood the flow that stderr messages take (and we don't blame you, we confused ourselves there!). While we sent the output of the cat command to /dev/fd/2, we used >, which sends stdout and not stderr.
So in our example, we just abused the stderr file descriptor to print to the Terminal; bad practice. We promise not to do it again. Now then, how can we actually work with stderr messages?
reader@ubuntu:/tmp$ cat /root/cat: /root/: Permission deniedreader@ubuntu:/tmp$ cat /root/ 1> error-filecat: /root/: Permission deniedreader@ubuntu:/tmp$ ls -l-rw-rw-r-- 1 reader reader 0 Nov 5 20:35 error-filereader@ubuntu:/tmp$ cat /root/ 2> error-filereader@ubuntu:/tmp$ ...