试图在python中使用aws命令获取文件名。但出现错误。
import subprocess
output=subprocess.check_output(['aws', 's3', 'ls', 's3://dev-lake/staging/20181111/', '--recursive', '--human-readable', '--summarize', '|','awk', '{print $4}'])
print output
错误
Unknown options: |,awk,{print $4}
Traceback (most recent call last):
File "list.py", line 2, in <module>
output=subprocess.check_output(['aws', 's3', 'ls', 's3://sdx-dev-lake/staging/20181111/', '--recursive', '--human-readable', '--summarize', '|','awk', '{print $4}'])
File "/usr/lib64/python2.7/subprocess.py", line 219, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['aws', 's3', 'ls', 's3://sdx-dev-lake/staging/20181111/', '--recursive', '--human-readable', '--summarize', '|', 'awk', '{print $4}']' returned non-zero exit status 255