Originally Posted by stranger
I am having troble understanding this command.
Let me know if the way I understand is correct.
Here's the command :
cat data.txt 2> output.txt 2>&1
My answer: read the error output of the data.txt file and put it in output.txt
and vise versa.
Thanks foe helping.
The cat data.txt 2> prints the file data.txt to STDOUT and redirects the output from STDERR into the file output.txt
The 2>&1 redirects STDERR to STDOUT after cat has written its STDERR to output.txt
The result will be an empty output.txt file and data.txt echoed to STDOUT. Like this:
$ cat data.txt
$ cat data.txt 2> output.txt 2>&1
$ cat output.txt