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?

4
  • 2
    cmd 2>&1 | tee file Commented May 13, 2014 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 :) Commented May 13, 2014 at 13:22
  • @glennjackman Your shell gold badge would magically close this in a click. See meta.stackoverflow.com/questions/254589/… Commented May 13, 2014 at 13:26
  • 1
    @teaLeef Use unbuffer as mentioned in one of the answers in the linked question. Commented May 13, 2014 at 13:27

1 Answer 1

1

Write output to file and than read it with cat:

python myscript.py >> output.txt | cat output.txt
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.