【发布时间】:2017-07-18 10:33:02
【问题描述】:
subprocess.call(["find", ".", "-exec", "sh", "-c", "echo testFirst", ";"])
subprocess.call(["find", ".", "-exec", "sh", "-c", "echo testSecond", ";"], shell=True)
subprocess.call(["find . -exec sh -c 'echo testThird' \\;"], shell=True)
subprocess.call(["find", ".", "-exec", "sh", "-c", "touch testFirst", ";"])
subprocess.call(["find", ".", "-exec", "sh", "-c", "touch testSecond", ";"], shell=True)
subprocess.call(["find . -exec sh -c 'touch testThird' \\;"], shell=True)
以下输出:
testFirst
testFirst
testFirst
.
./test.py
./data
testThird
testThird
testThird
.
./test.py
./testFirst
./data
并且只创建testFirst 和testThird 文件。
行为的解释是什么?
我假设输出为testFirst、testSecond、testThird 以及正在创建的三个文件。
【问题讨论】:
-
为什么需要前 4 个参数?
-
这不是我的实际代码,我只是缩小范围来演示问题。
标签: python subprocess