【发布时间】:2018-01-23 15:24:52
【问题描述】:
我想从 python 程序运行 bash 脚本。该脚本有这样的命令:
find . -type d -exec bash -c 'cd "$0" && gunzip -c *.gz | cut -f 3 >> ../mydoc.txt' {} \;
通常我会运行如下子进程调用:
subprocess.call('ls | wc -l', shell=True)
但这在此处是不可能的,因为引用符号。有什么建议吗?
谢谢!
【问题讨论】:
-
你能用
\转义'标记吗? -
哇。它确实有效。我不认为它会起作用,因为另一个命令正在每个子目录中。谢谢!
标签: python bash shell subprocess popen