Com csh , tcsh , zsh ou versões recentes de bash , tente
gcc hello.c |& tee file.txt
onde
- | & instruir o shell a redirecionar o erro padrão para a saída padrão.
Em outras camadas parecidas com Bourne:
gcc hello.c 2>&1 | tee file.txt
Em shells iguais a rc :
gcc hello.c >[2=1] | tee file.txt
No fish shell:
gcc hello.c ^&1 | tee file.txt