3 ms·
So you are supposed to read it from right to left? "First take 1 and throw it away. Next put 4 in 1." Is that how it works?
by im3w1l 5y ago
So you are supposed to read it from right to left? "First take 1 and throw it away. Next put 4 in 1." Is that how it works?
- kubanczyk 5y agoNot quite. Left to right: copy the descriptor 1 onto descriptor 4, change descriptor 1 to result of open("/dev/null"). The >& is for copying the descriptor not for aliasing ("hardlinking") it. The descriptor is the "fd" argument, e.g.: write(int fd, const void *buf, size_t count)
- vultour 5y agoNo, it’s like assigning variables. The second part overwrites the value of 1, but the first part is still using the old value.
- dgrunwald 5y agoNo, it's from left to right. It's basically just syntax for a series of dup2() calls. "4>&1 1>/dev/null" means: streams[4] = streams[1]; streams[1] = open("/dev/null");