![]() | 1 cheneydog 2017-05-05 19:52:58 +08:00 ![]() ls /xxx >list |
![]() | 2 sheep3 2017-05-05 19:55:13 +08:00 ``` import subprocess cat = subprocess.Popen(["ll",], stdout=subprocess.PIPE) for line in cat.stdout: print line ``` |
![]() | 3 dsg001 2017-05-05 20:24:59 +08:00 ``` import glob for file in glob.iglob('path'): print(file) ''' |
![]() | 4 /div> minbaby 2017-05-05 20:35:26 +08:00 一看楼上就是没有遇到过几百万文件在一个目录的情况,之前遇到过(因为 crontab 用了 wget 导致的),用 ls 命令已经不好使了,这个时候只能通过文件名字的规律来处理了,比如文件名是五位数字,可以试试 ls 11* 这种方式缩小每次读取的文件数量 |
![]() | 5 rrfeng 2017-05-05 20:38:43 +08:00 ![]() ls -U |
![]() | 6 Osk 2017-05-05 21:40:31 +08:00 ![]() $ time ls -U | wc -l 5973243 real 0m2.330s user 0m1.743s sys 0m0.790s 不用-U 要 24 秒多 |
![]() | 8 Ouyangan 2017-05-05 21:55:18 +08:00 100 万 , 真刺激 |
![]() | 9 lxf1992521 2017-05-05 22:07:10 +08:00 find > a 生成索引,在使用 python 去处理一个几百万行的文本即可。 |
10 dbj1991 OP |
![]() | 12 ihciah 2017-05-06 22:03:06 +08:00 想起某童鞋经历过的 inode 用完的情况。。。。 |