Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Python执行复杂的shell find命令?_Python_Bash_Subprocess - Fatal编程技术网

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

如何从Python执行复杂的shell find命令?,python,bash,subprocess,Python,Bash,Subprocess,我试图从python内部执行一个复杂的shell命令。天真的尝试: subprocess.call(["find", ".", "-exec touch {} \;"], cwd=".") 这是失败的。我该怎么做呢 subprocess.call(["find", ".", "-exec", "touch", "{}", ";"]) 不需要cwd=“”,因为它是默认值 cwd=“.”是不需要的,因为它是默认值。默认为“.”是一个扩展(我认为它是一个GNU扩展)。需要命令行中的路径。默认为“.

我试图从python内部执行一个复杂的shell命令。天真的尝试:

subprocess.call(["find", ".", "-exec touch {} \;"], cwd=".")
这是失败的。我该怎么做呢

subprocess.call(["find", ".", "-exec", "touch", "{}", ";"])
不需要cwd=“”,因为它是默认值

cwd=“.”是不需要的,因为它是默认值。

默认为“.”是一个扩展(我认为它是一个GNU扩展)。需要命令行中的路径。默认为“.”是一个扩展(我认为它是GNU扩展)。需要命令行中的路径。