This commit is contained in:
2022-08-28 09:57:48 +08:00
parent b7a0a5c104
commit 84be98ac74
20 changed files with 3211 additions and 0 deletions

View 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