“ls”命令、CSH 的列表太长
我想获取多个目录中所有 ofl
类型文件的列表。我使用了以下命令:
ls RESULTS/*/quakesim/iecrud/quake/fgb/stflt/*.ofl
但收到一条消息:/bin/ls: Argument list too long.
这样的文件有 1600 多个。有没有办法仍然获取文件列表?
编辑:
我需要文件的路径,而不仅仅是有多少个wc
是为了尝试查看我有多少文件而不用“污染”我的屏幕1600 多个路径。
I want to get a list of all my files of ofl
type in several directories. I used the fallowing command:
ls RESULTS/*/quakesim/iecrud/quake/fgb/stflt/*.ofl
but I got a message: /bin/ls: Argument list too long.
There are a little more than 1600 such files. Is there a way to still get the list of files?
EDIT:
I need the paths to the files and not just how many are there the wc
was as a try to see how many files I have without "polluting" my screen with 1600+ paths.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能很脏,但它适合我的需求并在我的能力范围内。我不认为它执行得很快,但它让我可以继续我的一天。
我得到了 90,000 个 jpg 长列表,并将它们通过管道传输到 avconv 以生成延时摄影。
我以前使用的是 ls *.jpg| avconv 在我遇到这个问题之前。
This might be dirty but it works for my needs and within my competency. I don't think it performs very quickly but it allowed me to get on with my day.
I was getting a 90,000 long list of jpgs and piping them to avconv to generate a timelapse.
I was previously using ls *.jpg| avconv before I ran into this issue.
您可以制作一个快速的 bash 脚本,为两颗星之一迭代从 a 到 z 的不同字母,然后,对于每个结果,将 wc 的结果添加到每次迭代的当前总数中,然后返回结果。
是否可以工作
您还可以查看仅使用:在两个不同的命令上 。可能更简单,尽管我不知道参数数量的限制。
You could make a quick bash script that iterates through different letters from a to z for one of your two stars, then, for each results, you add the result from wc to the current total for each itteration and you return the result.
You could also see if it would work just using:
on just two different commands. Might be simplier, although I do not know the limit of number of arguments.
使用
find
而不是ls.
示例:(假设您当前的工作目录是 RESULTS 的父目录)
find . -name "RESULTS/*/quakesim/iecrud/quake/fgb/stflt/*.ofl" -print
第二个选项:
find . -打印| egrep '.ofl$'
Use
find
instead ofls
.Example: (assuming your current working directory is the parent of RESULTS)
find . -name "RESULTS/*/quakesim/iecrud/quake/fgb/stflt/*.ofl" -print
Second option:
find . -print | egrep '.ofl$'