如何从Python执行复杂的shell find命令? [英] How do I execute a complex shell find command from Python?
本文介绍了如何从Python执行复杂的shell find命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从python内部执行复杂的shell命令.天真的尝试:
I'm trying to execute a complex shell command from inside of python. The naive attempt:
subprocess.call(["find", ".", "-exec touch {} \;"], cwd=".")
失败.我该怎么做呢?
推荐答案
subprocess.call(["find", ".", "-exec", "touch", "{}", ";"])
cwd =."不需要,因为它是默认值.
cwd="." Is not needed as it is the default.
这篇关于如何从Python执行复杂的shell find命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文