Tag: wc

如何快速计算线?

我尝试了unxutils的wc -l但它崩溃了1GB的文件。 我试过这个C#代码 long count = 0; using (StreamReader r = new StreamReader(f)) { string line; while ((line = r.ReadLine()) != null) { count++; } } return count; 它在4秒内读取500MB文件 var size = 256; var bytes = new byte[size]; var count = 0; byte query = Convert.ToByte(‘\n’); using (var stream = File.OpenRead(file)) { int many; do […]