更新
This commit is contained in:
32
Linux下打开超大文件方法.md
Normal file
32
Linux下打开超大文件方法.md
Normal file
@ -0,0 +1,32 @@
|
||||
Linux下打开超大文件方法
|
||||
|
||||
在Linux下用VIM打开大小几个G、甚至几十个G的文件时,是非常慢的。
|
||||
|
||||
这时,我们可以利用下面的方法分割文件,然后再打开。
|
||||
|
||||
1 查看文件的前多少行
|
||||
|
||||
head -10000 /var/lib/mysql/slowquery.log > temp.log
|
||||
|
||||
上面命令的意思是:把slowquery.log文件前10000行的数据写入到temp.log文件中。
|
||||
|
||||
2 查看文件的后多少行
|
||||
|
||||
tail -10000 /var/lib/mysql/slowquery.log > temp.log
|
||||
|
||||
上面命令的意思是:把slowquery.log文件后10000行的数据写入到temp.log文件中。
|
||||
|
||||
3 查看文件的几行到几行
|
||||
|
||||
sed -n '10,10000p' /var/lib/mysql/slowquery.log > temp.log
|
||||
|
||||
上面命令的意思是:把slowquery.log文件第10到10000行的数据写入到temp.log文件中。
|
||||
|
||||
|
||||
|
||||
4 根据查询条件导出
|
||||
cat catalina.log | grep '2017-09-06 15:15:42' > test.log
|
||||
|
||||
|
||||
5 实时监控文件输出
|
||||
tail -f catalina.out
|
Reference in New Issue
Block a user