我想要做的事很簡單。我想用python的subprocess
模塊調用下面的命令。使用大於subprocess.call的操作符
cat /path/to/file_A > file_B
的命令只是作品和複印件在當前工作目錄中的file_A
內容file_B
。但是,當我嘗試在腳本中使用subprocess
模塊調用此命令時,它會出錯。以下是我在做什麼:
import subprocess
subprocess.call(["cat", "/path/to/file_A", ">", "file_B"])
,我得到以下錯誤:
cat: /path/to/file_A: No such file or directory
cat: >: No such file or directory
cat: file_B: No such file or directory
我究竟做錯了什麼?如何使用子進程模塊call
命令使用大於運算符?
我不完全複製一個文件,但使用'sed'提取一部分。 – Amyth
@Amyth:當然,Python也可以提取。 –