简体   繁体   English

如何从Python执行复杂的shell find命令?

[英]How do I execute a complex shell find command from Python?

I'm trying to execute a complex shell command from inside of python. 我正在尝试从python内部执行复杂的shell命令。 The naive attempt: 天真的尝试:

subprocess.call(["find", ".", "-exec touch {} \;"], cwd=".")

is failing. 失败了。 How do I go about doing this? 我该怎么做呢?

subprocess.call(["find", ".", "-exec", "touch", "{}", ";"])

cwd="." cwd =“。 Is not needed as it is the default. 不需要,因为它是默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM