I was learning about I/O redirection and tried out the following command.
ls -l /bin/ > bin_contents.txt > bin_contents_copy.txt
I do understand that redirection doesn't work between files. But, on running the command, I expected the output stream data of the ls command to be stored in the first file i.e. bin_contents.txt. Since the output stream redirection from ls command is given directly to this file. And expected the second file, bin_contents_copy.txt file to be empty (since redirection doesn't work between files).
But when I ran the command, I found the contrary to be true. The output stream of ls command is stored in the second file i.e. bin_contents_copy.txt rather than the file bin_contents.txt. Why does that happen?