我有一个python程序,我尝试从命令行执行一些打印。我想将输出重定向到一个文件,并在shell上看到打印结果。我试过cmd > file
, cmd >> file
和cmd &> file
。但是使用这三个命令,打印既不在shell中,也不在文件中。为什么?
将输出写入文件,然后使用cat:
读取python myscript.py >> output.txt | cat output.txt