1、查询字符串命令: cat fileName|grep '要查找的字符串'
实例:cat catalina.out|grep '2018041417434200258001'
2、根据某个字符串,查询该字符串前后文本信息命令:grep-A|B n"key"file
其中:
A:表示在字符串之后 after context
B:表示在字符串之前 before context
n:要获取多少行文本 line number
key:为要查找的字符串
file:文件名
实例:grep -A 100 -B 100 -i '抓不到我' catalina.out
-i表示忽略大小写。
当然,如果我们想获取异常日志的前10行和后10行,不用加-A和-B,使用如下命令就可以了:
实例:grep -10 -i '抓不到我' catalina.out
3、# Linux查看文件或文件夹大小du命令
使用实例:
1、查看当前目录总共占的容量,而不单独列出各子项占用的容量 ,在所在目录输入du -sh:

2、查看当前目录下一级子文件和子目录占用的磁盘容量:



3、统计当前文件夹(目录)大小,并按文件大小排序:

4、查看指定文件大小可以使用du -sh或du -a:

5、列出当前目录中的目录名不包括某字符串的目录的总大小:

参考:https://blog.csdn.net/Tastill/article/details/80227541
https://www.cnblogs.com/Sungeek/p/11661554.html
网友评论