Step4 | Standard Streams and File Descriptors | 6.Duplicating File Descriptors

For question2 " 1. Discard both output streams of any command, by duplicating 1 into 2 and redirecting them to /dev/null.", I quite don’t understand why any command has 2 output streams…And why does the answer meet the requirement? Would you please explain?

@xuyangchen8635: Generally standard output (stdout, e.g. result of addition etc.) and standard error (stderr, e.g. Syntax Error, ValueError etc.) are passed to the “output” (i.e. if you have say a print statement with an error another line of your code after the print, the printed characters/strings/ints etc. would get displayed followed by the error message). Having a more visual aid such as the video below might be useful (video demo is in C but concepts are the same). Let me know if it helps!

Also as described in the instructions/background context:

Running command 2>&1 will copy file descriptor 1 into 2. This means that whatever is written to fd 2 will go to where fd 1 goes.

1 Like

U know for some reason I watched this exactly today (for my work as I was trying to debug some C/Assembly code for my internship) and then I saw your question haha… Not sure if it was pure conincidence :sweat_smile: