0

I can redirect stdout and stderr to a file like below

some_command.sh >> file.txt 2>&1

Can someone let me know how can I redirect stdout and stderr to a file and also to console?

tuk
  • 5,941
  • 14
  • 79
  • 162

1 Answers1

0

The tee command can help you out. It reads from standard input and writes to standard output and files.

So the following command will do:

some_command.sh 2>&1 | tee file.txt

Manpage: http://man7.org/linux/man-pages/man1/tee.1.html

Yuankun
  • 6,875
  • 3
  • 32
  • 34