So I am trying to learn more about file descriptors and their redirections. At the moment I am exploring an edge case of doing 1>&0 and I cannot quite understand what is happening there.$ echo hello 1>&0helloSo in this case, hello is printed even though I redirected stdout to stdin. I expected nothing to be printed.Can you explain to me why hello is printed?
Behaviour of 1>&0 in bash
bash;shell;io redirection;file descriptors
Both descriptors 0 and 1 were connected to your terminal in read + write mode, so this redirection changes nothing. On Linux, you can find all your current descriptors under /proc/self/fd, for example in my case:$ ls -l /proc/self/fdlrwx------ 1 jimmij jimmij 64 Jan  3 17:42 0 -> /dev/pts/2lrwx------ 1 jimmij jimmij 64 Jan  3 17:42 1 -> /dev/pts/2lrwx------ 1 jimmij jimmij 64 Jan  3 17:42 2 -> /dev/pts/2lr-x------ 1 jimmij jimmij 64 Jan  3 17:42 3 -> /proc/5263/fdAs you can see 0, 1 and 2 are all linked to pseudoterminal /dev/pts/2.