重定向程序输出到文件和shell



我有一个python程序,我尝试从命令行执行一些打印。我想将输出重定向到一个文件,并在shell上看到打印结果。我试过cmd > file, cmd >> filecmd &> file。但是使用这三个命令,打印既不在shell中,也不在文件中。为什么?

将输出写入文件,然后使用cat:

读取
python myscript.py >> output.txt | cat output.txt

最新更新