将 gunzip 输出重定向到 python 脚本
Redirect gunzip output to python script
我想要 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
输出中读取。
sys.argv
用于命令行参数。您没有传递任何这些,而是通过 stdin 将其通过管道输入。所以你需要阅读 sys.stdin
.
我想要 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
输出中读取。
sys.argv
用于命令行参数。您没有传递任何这些,而是通过 stdin 将其通过管道输入。所以你需要阅读 sys.stdin
.