0

I want to gunzip a series of files and then redirect the output to my python script. The python script gets one argument as the input. I wrote the following command:

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

But it gives me the following error:

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

I wonder why it can't read from the gunzip output.

4

1 回答 1

3

sys.argv用于命令行参数。您没有通过任何这些,而是​​通过标准输入将其输入。所以你需要从sys.stdin.

于 2015-08-31T17:31:46.550 回答