December 2018
Beginner
452 pages
12h 17m
English
In reality, all data sent (actually, written) to /dev/null will be discarded, but nonetheless generate a write operation succeeded back to the calling command. In this case, that would be the redirection.
This is important, because look what happens when a redirection is unable to complete successfully:
reader@ubuntu:~/scripts/chapter_12$ ./stderr &> /root/file-bash: /root/file: Permission deniedreader@ubuntu:~/scripts/chapter_12$ echo $?1
This operation fails (because the reader user obviously can't write in the home directory of the root superuser).
Look at what happens when we try the same thing with /dev/null:
reader@ubuntu:~/scripts/chapter_12$ ./stderr &> /dev/null reader@ubuntu:~/scripts/chapter_12$ echo $?0reader@ubuntu:~/scripts/chapter_12$ ...