bash:/bin/ls:参数列表太长 [英] bash: /bin/ls: Argument list too long
问题描述
我需要列出大量文件(40,000个文件)的列表,如下所示:
I need to make a list of a large number of files (40,000 files) like below:
ERR001268_1_100.fastq ERR001268_2_156.fastq ERR001753_2_78.fastq
ERR001268_1_101.fastq ERR001268_2_157.fastq ERR001753_2_79.fastq
ERR001268_1_102.fastq ERR001268_2_158.fastq ERR001753_2_7.fastq
ERR001268_1_103.fastq ERR001268_2_159.fastq ERR001753_2_80.fastq
我的命令是:ls ERR*_1_*.fastq |sed 's/\.fastq//g'|sort -n > masterlist
但是错误是:bash: /bin/ls: Argument list too long
my command is: ls ERR*_1_*.fastq |sed 's/\.fastq//g'|sort -n > masterlist
However error is: bash: /bin/ls: Argument list too long
但是我可以解决这个问题吗? 还有其他通过perl/python创建列表的方法吗?
However can I solve this problem? Any other way to make list like this by perl/python?
thx
推荐答案
您应该可以将ls ERR*_1_*.fastq
替换为find . -name "ERR*_1_*.fastq"
.
这样,您可以避免将通配符扩展为庞大的参数列表.
You should be able to replace ls ERR*_1_*.fastq
with find . -name "ERR*_1_*.fastq"
.
This way, you can avoid having the wildcard expand into a huge argument list.
(find
输出将包含前导"./",例如./ERR001268_1_100.fastq
.如果
这是不希望的,您可以在稍后的版本中使用另一个sed
命令将其删除.
管道.)
(The find
output will include a leading "./", e.g. ./ERR001268_1_100.fastq
. If
that's undesirable, you can get rid of it with another sed
command later in the
pipeline.)
这篇关于bash:/bin/ls:参数列表太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!