我有一个较大的服务器日志文件(~750 MB),无法使用Notepad或Notepad ++打开(它们都会显示文件太大)。
有人能建议一个程序(适用于Windows),每次仅将文件的一小部分读入内存吗?
还是我需要编写自己的应用程序来解析这个文件?
我有一个较大的服务器日志文件(~750 MB),无法使用Notepad或Notepad ++打开(它们都会显示文件太大)。
有人能建议一个程序(适用于Windows),每次仅将文件的一小部分读入内存吗?
还是我需要编写自己的应用程序来解析这个文件?
使用EmEditor,非常好用,我用它打开了一个超过500MB的文件。
Total Commander的综合文本查看器可以轻松查看巨大的文件(>10GB),并且提供不同的视图,例如十六进制视图。
我使用 BareTail 已经有一段时间了,用于查看大型日志文件(达到几个GB),它的工作效果非常好,运行速度也快。这款软件有免费版和商业专业版。
他们 说 它具有以下功能:
另一个选择是 Far Manager。查看几GB的文件不会成为问题(内存占用小),但在编辑模式下打开文本文件可能需要几GB的RAM,请注意。我不知道在Far中可以查看/编辑的文件大小限制。
less
来读取一个3GB的文件,但最终我还是使用grep
查找我需要的内容。( less
比more
更好。)有关less
的更多详细信息,请参见此答案:https://dev59.com/cnVC5IYBdhLWcg3w21Mq#1343576。如果你会编码,可以写一个控制台应用程序。以下是C#版本的代码示例,你可以根据自己需求对结果进行分割、执行等操作:
SqlCommand command = null;
try
{
using (var connection = new SqlConnection("XXXX"))
{
command = new SqlCommand();
command.Connection = connection;
if (command.Connection.State == ConnectionState.Closed) command.Connection.Open();
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader("C:\\test.txt"))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
command.CommandText = line;
command.ExecuteNonQuery();
Console.Write(" - DONE");
}
}
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
finally
{
if (command.Connection.State == ConnectionState.Open) command.Connection.Close();
}