0

I have a python program that makes some prints that I try to execute from the command line. I would like to redirect the output to a file and also see on the shell the prints. I tried cmd > file, cmd >> file and cmd &> file. But with these three commands, the prints are neither in the shell nor in the file. Why?

teaLeef
  • 1,879
  • 2
  • 16
  • 26
  • 2
    `cmd 2>&1 | tee file` – devnull May 13 '14 at 13:13
  • @glennjackman I guess that the referenced dup sums it up pretty well. Nothing new to add here. (Although finding a suitable dup took a while :) – devnull May 13 '14 at 13:22
  • @glennjackman Your shell gold badge would magically close this in a click. See http://meta.stackoverflow.com/questions/254589/when-did-i-get-superpowers – devnull May 13 '14 at 13:26
  • 1
    @teaLeef Use `unbuffer` as mentioned in one of the answers in the linked question. – devnull May 13 '14 at 13:27

1 Answers1

1

Write output to file and than read it with cat:

python myscript.py >> output.txt | cat output.txt
Josip Grggurica
  • 421
  • 4
  • 12