Issue
I'm trying to save stdout of a command to output file output.txt
I can't understand why when I use &>
everything is okay and when I use >
some strange symbols like [0m[0;1;32m
appear randomly throughout the file.
What could cause that?
My investigations shows that these symbols are terminal coloring. But why they disappear when I use &>?
Solution
It probably checks whether stderr
is connected to a terminal and if it is than it uses color control codes. When you redirect with &>
both stdout
and stderr
are not connected to a terminal, so no colour codes are used.
Answered By - Maxim Egorushkin