Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个从 csv 文件读取并打印到标准输出的 python 脚本。默认输出必须是标准输出,而不是直接输出到文件。当我在 bash 中执行此脚本时,如下所示:
program.py > file.csv
其中输出 file.csv 与 python 脚本正在读取的相同,它会失败。原因是 bash 在执行 python 程序之前显然会删除 file.csv。如何在 bash 中执行此操作,以便在 python 程序完成执行后删除文件?
你可以做一些丑陋的事情,比如
program.py > tmp.csv && mv tmp.csv file.csv