将gunzip输出重定向到python脚本

2024-09-29 01:35:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我想gunzip一系列文件,然后将输出重定向到我的python脚本。python脚本获取一个参数作为输入。我写了以下命令:

for i in $(ls test5/*/*gz); do gunzip -c $i | python script.py ; done

但它给了我以下错误:

Traceback (most recent call last):
  File "./fqtofa.py", line 7, in <module>
    inFile = sys.argv[1]
IndexError: list index out of range

我想知道为什么它不能读取gunzip输出。你知道吗


Tags: 文件inpy命令脚本for参数script