0

In case you have file1 and file2, but file3 does not exist, the following command will output the valid part to outfile, and then append the error to the end of outfile:

cat file1 file2 file3 1>outfile 2>&1  

But if you change the order:

cat file1 file2 file3 2>&1 1>outfile 

The error is printed into the terminal (&1) despite the fact the terminal is redirected to outfile. I'm confused, what is the proper way to understand both commands?

Thanks.

Mister_L
  • 2,469
  • 6
  • 30
  • 64
  • This might help: `man bash | less +/^REDIRECTION` – Cyrus Oct 24 '18 at 19:18
  • You will get an answer from someone but to me this is terrible coding practice ... CHECK your files THEN try to read them. – Mike Q Oct 24 '18 at 19:24
  • 2
    [This article](http://wiki.bash-hackers.org/howto/redirection_tutorial#order_of_redirection_ie_file_2_1_vs_2_1_file) should be helpful. – Benjamin W. Oct 24 '18 at 19:29

0 Answers0